[Haskell-cafe] Re: subsequence
peterstranney at yahoo.co.uk
Sun Oct 17 09:55:07 EDT 2004
>> I am stuck on an exercise in a haskell book (the craft of functional
>> programming) chapter 7 exercise 7.18 I have to write a function to
>> does one list occur as a subsequence of another, i am having real
>> difficulty trying to do this. I have a method which will tell me if
>> character occurs in the list but it won't work for a list of
>> the function should look like isSubsequence :: [chars] -> [chars] ->
>Try writing a list or string equality function first? That may help.
Thanks for getting back to me, have written this so far
find :: [Char] -> Char -> Bool
find  n = False
find (x:xs) n
| x == n = True
| otherwise = find xs x
this will work to find if one character appears in a list but i dont understand how to call this recursively to find if a list occurs within a list. I have tried writing another function to call this but it won't work. Does anyone have a solution?
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe