One possible way to generate the values would be using a generic function for permutation with repetition, such as:<br><span style="font-family: monospace;"><br></span>permuteRep :: [a] -> [b] -> [[(a,b)]]<span style="font-family: monospace;">
<br></span>permuteRep [] _ = []<span style="font-family: monospace;"><br></span>permuteRep (a:[]) bs = [ [ (a,b) ] | b <- bs ]<span style="font-family: monospace;"><br></span>
permuteRep (a:as) bs = concat [ [ (a,b):p | p <- permuteRep as bs ] | b <- bs ]<br><br>and then use:<br><br>lines = permuteRep ["x","y","z"] [False,True]<br><br>In case the variable names can be discarded (or, in this case, not generated ... lazy evaluation rox ;-), then:
<br><br>map (map snd) lines<br><br>This avoids having to provide a "domain" for each variable in the list comprehension, which could be problematic when dealing with many variables<br><br><div><span class="gmail_quote">
On 2/21/07, <b class="gmail_sendername">Joe Thornber</b> <<a href="mailto:joe.thornber@gmail.com">joe.thornber@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> On 2/10/07, Peter Berry <<a href="mailto:pwberry@gmail.com">pwberry@gmail.com</a>> wrote:<br>> Prelude> putStrLn $ concatMap (flip (++)"\n") $ map show $ [(x,y,(&&) x y)<br>> |x <- [True,False],y <- [True,False]]
<br><br>This can be simplified slightly to:<br><br>Prelude > putStrLn . unlines . map show $ [(x, y, x && y) | x <-<br>[True, False], y <- [True, False]]<br><br><br>- Joe<br>_______________________________________________
<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe
</a><br></blockquote></div><br><br clear="all"><br>-- <br>Ricardo Guimarães Herrmann<br>"Those who do not understand Lisp are doomed to reinvent it, poorly"<br>"Curried food and curried functions are both acquired tastes"
<br>"If you think good architecture is expensive, try bad architecture"