プログラミングのお題スレ Part18
(ID:3QUkzPB/のみ表示中)
戻る
157デフォルトの名無しさん

AAS

NG

>>155

確かこんなのあったな〜・・・と、inword/outword関数の相互再帰で書いてみた。

Haskell

main = (putStrLn.f "abcdefrt") "acdgefgg"

f xs ys | g xs ys =[]
f (x:xs) (y:ys) | x == y = outword (x:xs) (y:ys)
f xs ys = inword xs ys

inword xs ys | g xs ys = ']':[]
inword (x:xs) (y:ys) | x == y = ']':x:outword xs ys
inword (x:xs) (_:ys) = x:inword xs ys

outword xs ys | g xs ys = []
outword (x:xs) (y:ys) | x == y = x:outword xs ys
outword (x:xs) (_:ys) = '[':x:inword xs ys

g xs ys = or [null xs, null ys]

2020/07/26(日)23:12:10.92(3QUkzPB/.net)


戻る
ver.151005sp