
30 Oct
2009
30 Oct
'09
8:36 a.m.
On Fri, Oct 30, 2009 at 12:44 PM, Matthias Guedemann
Now I want to make it capable to create all combinations of length n instead of fixed length 3 (that's why list instead of tuple), but I don't really see how.
If I understood what you ask this time, there's a function in Control.Monad that does it : allN = replicateM replicateM 4 [ 1,2,3 ] = [ [ 1,1,1,1],[1,1,1,2], .... when you write a <- ls b <- ls c <- ls You perform the monad "action" 3 times, collecting the result in a then b, then c. now replicateM performs a monad action n times, collecting the result in a list. turns out that making a list of the result is exactly what you want. David.