First, I'd refer you to this list's rules on homework, and what people
will or won't answer.
Secondly to that though, rather than provide a solution, I'll give you
an idea that may lead to you coming up with a solution. First, try
and write a function that can test if your first list is at the start
of the second list:
startlist [2,3] [2,3,4,5]
True
startlist [2,3] [1,2,3,4]
False
Then use this function to write your sublist function.
Hope that helps
Tom Davie
On 24 Apr 2008, at 10:29, cetin tozkoparan wrote:
I have a problem which i can't solve. Is there any one who has an
idea?
Two lists is sent as parameter to a function. If second list
contains first list, return true, else return false. This
comparision must be in order of first list. You can look at examples.
function type as follows:
sublist:: [a] - [a] - Bool
examples:
For instance [2,4,5] list is sub list of [3,7,2,4,5,9] list but not
of [3,7,4,2,5,9] list.
sublist [2,8] [1,5,6,2,4,7,8,2]
False
sublist [1,2,3] [0,1,2,3,4,5,6]
True
sublist [5,4] [1,4,5,7,8,3,5,4]
True
sublist [1,2,4,3,4,5,7,8,9,5] [8,2,3,1,2,4,3,4,5,7,8,9,5,1,6,2]
True
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
Try it now.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe