Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  set multiplication (Christian Maeder)


----------------------------------------------------------------------

Message: 1
Date: Tue, 08 Apr 2014 09:06:29 +0200
From: Christian Maeder <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] set multiplication
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Some time ago I discovered that the monadic "sequence" function operates 
quite interestingly on lists. I don't know why you call it 
multiplication. I was looking for something like combinations:

Prelude> sequence [[1,2,3], [4,5], [6,7]]

HTH Christian

Am 08.04.2014 07:00, schrieb Nishant:
>
> hi,
>
> I am trying to implement a set multiplication program in haskell.
>
> Input : [1,2,3]   [4,5]  [6,7]
> Ouput : [ [1,4,6] , [1,4,7] , [1,5,6] , [1,5,7] ...]
>
>
> I implemented it for constant number of inputs like
>
> setMul xs ys zs =  [ [x] ++ [y] ++ [z] |  x <- xs , y<-ys ,z <- zs]
>
> I am not able to generalize this for any number of lists.
>
> type signature would be :
>
> setMulMany :: [[a]] -> [[a]]
>
> Example :
>
> Input : [ [1,2,3] , [4,5] , [6,7]]
> Ouput :  [ [1,4,6] , [1,4,7] , [1,5,6] , [1,5,7] ...]
>
>
> Regards.
> Nishant
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 70, Issue 17
*****************************************

Reply via email to