
17 Oct
2004
17 Oct
'04
5:53 p.m.
Peter Simons wrote:
This version should do it:
isSubSeq :: (Eq a) => [a] -> [a] -> Bool isSubSeq [] _ = True isSubSeq _ [] = False isSubSeq (x:xs) (y:ys) | x == y = isSubSeq xs ys ^^^^^^^^
I think you want to refer to List.isPrefixOf here - your version is a sort of "ordered subset" test. I.e. I get: "abc" `isSubSeq` ".a.b.c." ===> True
| otherwise = isSubSeq (x:xs) ys
My version would've been: isSubSeq x = any (isPrefixOf x) . tails But Remi beat me to it (and for that I'll never forgive him! :-). Sam