find if list 1 is a sequence of list 2 in haskell
- by Isaak Wahb
im trying to check if a given list is a subsequence of another list:
here are example of lists which gives true:
subseq "" "w"
subseq "w" "w"
subseq "ab" "cab"
subseq "cb" "cab"
subseq "aa" "xaxa"
not (subseq "aa" "xax")
not (subseq "ab" "ba")
i just come to this but in some cases it gives a wrong result
subseq :: Eq a => [a] -> [a] -> Bool
subseq [] [] = True
subseq [] ys = True
subseq xs [] = False
subseq (x:xs) (y:ys) = x == y || subseq xs ( 1 `drop` ys )