One possible way to generate the values would be using a generic function for permutation with repetition, such as:

permuteRep :: [a] -> [b] -> [[(a,b)]]
permuteRep [] _ = []
permuteRep (a:[]) bs = [ [ (a,b) ] | b <- bs ]
permuteRep (a:as) bs = concat [ [ (a,b):p | p <- permuteRep as bs ] | b <- bs ]

and then use:

lines = permuteRep ["x","y","z"] [False,True]

In case the variable names can be discarded (or, in this case, not generated ... lazy evaluation rox ;-), then:

map (map snd) lines

This avoids having to provide a "domain" for each variable in the list comprehension, which could be problematic when dealing with many variables

On 2/21/07, Joe Thornber <joe.thornber@gmail.com> wrote:
> On 2/10/07, Peter Berry <pwberry@gmail.com> wrote:
> Prelude> putStrLn $ concatMap (flip (++)"\n") $ map show $ [(x,y,(&&) x y)
> |x <- [True,False],y <- [True,False]]

This can be simplified slightly to:

Prelude > putStrLn . unlines . map show $ [(x, y, x && y) | x <-
[True, False], y <- [True, False]]


- Joe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
Ricardo Guimarães Herrmann
"Those who do not understand Lisp are doomed to reinvent it, poorly"
"Curried food and curried functions are both acquired tastes"
"If you think good architecture is expensive, try bad architecture"