[Haskell-cafe] Newbie: generating a truth table

Henk-Jan van Tuyl hjgtuyl at chello.nl
Wed Feb 21 17:01:27 EST 2007


On 2007-02-21, Joe Thornber <joe.thornber at gmail.com> wrote:
>
> > On 2007-02-10, Peter Berry <pwberry at 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]]

This can be further simplified to:
   putStrLn $ unlines [show (x, y, x && y) | x <- [True, False], y <-  
[True, False]]

-- 
Met vriendelijke groet,
Henk-Jan van Tuyl


--
http://Van.Tuyl.eu/
--

Using Opera's revolutionary e-mail client:
https://secure.bmtmicro.com/opera/buy-opera.html?AID=789433



More information about the Haskell-Cafe mailing list