[Haskell-beginners] set multiplication

Nishant nishantgeek at gmail.com
Tue Apr 8 05:00:01 UTC 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140408/643ac8f9/attachment.html>


More information about the Beginners mailing list