On Sun, Oct 17, 2004 at 11:41:59AM -0700, Peter Stranney wrote:
> 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

Now that you found it, we might as well tell you the other
solution:

import List

-- Point-free (beware of the monomorphism-restriction)
isSubStrand' :: Eq a => [a] -> [a] -> Bool
isSubStrand' = flip (.) tails . any . isPrefixOf

-- and point-full
isSubStrand'' x y = any (x`isPrefixOf`) (tails y)

Groetjes,
Remi "feeling mean" Turk

-- 
Nobody can be exactly like me. Even I have trouble doing it.
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to