[Haskell-cafe] Subsequence near solved hopefully

Peter Stranney peterstranney at yahoo.co.uk
Sun Oct 17 14:41:59 EDT 2004

Thanks guys for all your help, finally through code, sweat and tears i have found the solution;
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

thanks again
Peter Stranney

Ketil Malde <ketil+haskell at ii.uib.no> wrote:
Remi Turk writes:

> You might also want to look at the earlier `any prefix of tails'
> suggestion, as it makes the solution a rather simple one-liner.

Wouldn't that be looking for a sub*string*, and not a (general)
sub*sequence* (which I think does not have to be contigous?)

If I haven't seen further, it is by standing in the footprints of giants

Peter Stranney

Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20041017/3a04e1eb/attachment.htm

More information about the Haskell-Cafe mailing list