[Haskell-cafe] Re: Subsequence near solved hopefully

Peter Simons simons at cryp.to
Sun Oct 17 15:52:55 EDT 2004


Sam Mason writes:

 > Just to muddy the water a bit. . . What happens if the
 > second string is infinite?

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
  | otherwise = isSubSeq (x:xs) ys

Peter



More information about the Haskell-Cafe mailing list