[Haskell-cafe] Fw: I have a problem
tom.davie at gmail.com
Thu Apr 24 05:50:52 EDT 2008
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]
> startlist [2,3] [1,2,3,4]
Then use this function to write your sublist function.
Hope that helps
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
> 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
> 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]
> sublist [1,2,3] [0,1,2,3,4,5,6]
> sublist [5,4] [1,4,5,7,8,3,5,4]
> 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]
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
> Try it now._______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe