Created
September 15, 2014 10:51
-
-
Save mmitou/bd982d1442f9a9ce20a3 to your computer and use it in GitHub Desktop.
subseqのサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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