
4 Nov
2009
4 Nov
'09
2:56 p.m.
Luke Palmer wrote:
I believe you can get what you want using the diagonal function from Control.Monad.Omega.
product xs ys = [ [ (x,y) | y <- ys ] | x <- xs ] diag2 xs ys = diagonal (product xs ys)
I think if you separate taking the cartesian product and flattening it, like this, you might have an easier time wrangling all the different variants you want.
Note that Control.Monad.Omega is not a monad. The law of associativity is broken, at least in a direct sense. Regards, apfelmus -- http://apfelmus.nfshost.com