# [Haskell] 2 programs VERY URGENT

Thomas Davie tatd2 at kent.ac.uk
Sat Aug 12 09:03:01 EDT 2006

```Also of note,  this channel is in large part made up of university
lecturers, researchers, and PhD students.  I really wouldn't be
surprised if one of them were to notice the assignment they set
cropping up here.

Bob

On 12 Aug 2006, at 13:58, Thomas Davie wrote:

> Hi,
>   While this is an interesting question, the haskell mailing list
> is not really the appropriate place to ask it.
>
> Questions here should be of the form of:
> • How do I work this feature of Haskell
> • What the hell does this error mean
> • Wouldn't it be cool if Haskell did this?
> • Is there a <insert dev tool here> for Haskell?
> • Is there a <insert library here> library for Haskell?
>
> They shouldn't be of the form:
> • Can you do my university assignement for me?
> • Can you write this piece of code for me?
>
> Although, you could probably get away with:
> • Here's a solution to this problem, how do I optimise it?
>
> Bob
>
> On 12 Aug 2006, at 13:23, Mohammad Mehdi Bezyan wrote:
>
>> Hello All
>>
>> There are 2 questions for my project and I need to aswer them as
>> soon as possible. The answers need to be written in Haskell using
>> recursive methods.
>>
>> The questions are the following:
>>
>>
>> Number 1:
>> The set of n-combinations of a set S is the set of subsets of S of
>> size n. Write a function combs :: Int -> [a] -> [[a]] which,
>> representing sets as lists, calculates n-combinations of a given
>> list. For example, combs 3 [1,3,5,6,9] is [[1,3,5],[1,3,6],[1,3,9],
>> [1,5,6],[1,5,9], [1,6,9],[3,5,6],[3,5,9],[3,6,9],[5,6,9]]
>> Within each combination, the n values should appear in the same
>> order as they appear in the original list (so, for example,
>> [1,5,3] should not appear instead of [1,3,5] in the result for
>> combs 3 [1,3,5,6,9]). But the list of combinations may appear in
>> any order (ie, [1,3,5] need not appear first in the result of
>> combs 3 [1,3,5,6,9]). You may assume that the list argument to
>> combs does not contain duplicate members.
>>
>> Number 2:
>> Given a list of lists, a list is in the Cartesian product of them
>> if it contains one member from each of them. Write a function
>> cart :: [[a]] -> [[a]] which calculates this. For example, cart
>> [[1,2], [4], [7,8,9]] is [[1,4,7],[1,4,8],[1,4,9],[2,4,7],[2,4,8],
>> [2,4,9]]
>> Each member of the Cartesian product must appear in the
>> appropriate order: eg, in [1,4,7] above, 1 appears first, then 4,
>> then 7, because 1 is from the first input list [1,2], 4 is from
>> the second input list [4], and 7 is from the third input list [7].
>> The list of members of the Cartesian product may appear in any
>> order (ie, [1,4,7] need not appear first in the list).
>>
>>
>> It would be very much appreciated if you could help me or provide
>> me with some code, please. I need them very soon.
>>
>> Thanks!
>> Send instant messages to your online friends http://
>> au.messenger.yahoo.com
>>
>> _______________________________________________
>> Haskell mailing list
>> Haskell at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell

```

More information about the Haskell mailing list