It's been a while since I last wrote any Haskell code, but try:

setMulMany :: [[a]] -> [[a]]
setMulMany = foldr mulOne [[]]
    where
        mulOne :: [a] -> [[a]] -> [[a]]
        mulOne xs yss = [ x:ys | x <- xs, ys <- yss]

I'm writing this from my phone, so didn't have a chance to test it really...

Hope it helps!

On Apr 8, 2014 2:00 AM, "Nishant" <nishantgeek@gmail.com> wrote:

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
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners