Skip to content

Instantly share code, notes, and snippets.

@mmitou
Created September 15, 2014 10:51
Show Gist options
  • Select an option

  • Save mmitou/bd982d1442f9a9ce20a3 to your computer and use it in GitHub Desktop.

Select an option

Save mmitou/bd982d1442f9a9ce20a3 to your computer and use it in GitHub Desktop.
subseqのサンプル
subseq :: (Eq a) => [a] -> [a] -> Bool
subseq seq sseq = subseq' seq sseq == seq
subseq' :: (Eq a) => [a] -> [a] -> [a]
subseq' seq sseq = foldr unifier [] sseq
where
unifier x [] | elem x seq = [x]
| otherwise = []
unifier x sseq'@(s:_)
| elem x seq && s /= x = (x:sseq')
| otherwise = sseq'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment