[Haskell-cafe] how can this code be less?
cetintozkoparan at yahoo.com
Thu Apr 24 21:27:32 EDT 2008
I wrote this code and Can it be less?
[2,4,5]list is sub list of [3,7,2,4,5,9] list and return True but not of[3,7,4,2,5,9] list ; return False
sublist :: Eq a => [a] -> [a] -> Bool
sublist  _ = True
sublist (_:_)  = False
sublist (x:xs) (y:ys)
| x == y = if isEqual (x:xs) (y:ys) == False
then sublist (x:xs) ys
| otherwise = sublist (x:xs) ys
isEqual :: Eq a => [a] -> [a] -> Bool
isEqual  _ = True
isEqual (_:_)  = False
isEqual (x:xs) (y:ys)
| x==y = isEqual xs ys
| otherwise = False
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe