[Haskell-cafe] how can this code be less?

cetin tozkoparan 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
                        else True
  | 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...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080424/97bc4898/attachment.htm


More information about the Haskell-Cafe mailing list