プログラミングのお題スレ Part18at TECH
プログラミングのお題スレ Part18 - 暇つぶし2ch160:デフォルトの名無しさん
20/07/26 23:12:10.92 3QUkzPB/.net
>>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]


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch