[Haskell-cafe] Subsequence near solved hopefully

Sam Mason mason at f2s.com
Sun Oct 17 15:40:05 EDT 2004


Peter Stranney wrote:
>isSubStrand:: String -> String -> Bool
>isSubStrand [] [] = True
>isSubStrand [] (y:ys) = False
>isSubStrand (x:xs) [] = False
>isSubStrand (x:xs) (y:ys)
>   | length(x:xs)>length(y:ys) = False
>   | take (length (x:xs)) (y:ys)==(x:xs) = True
>   | otherwise = isSubStrand (x:xs) ys

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

  Sam


More information about the Haskell-Cafe mailing list