[Haskell-cafe] Newbie: generating a truth table
yumagene at gmail.com
Tue Feb 20 23:46:25 EST 2007
On 2/10/07, Peter Berry <pwberry at gmail.com> wrote:
> Sigh, I seem to have done a reply to sender. Reposting to the list.
> On 06/02/07, phiroc at free.fr <phiroc at free.fr> wrote:
> > Hello,
> > I would like to create a Haskell function that generates a truth table,
> > all Boolean values, say, using the following "and" function :
> > and :: Bool -> Bool -> Bool
> > and a b = a && b
This is solution that I used with list comprehension.. combining some of the
other ideas on the thread such as a tuple to see the original values and
then the result.
Prelude> putStrLn $ concatMap (flip (++)"\n") $ map show $ [(x,y,(&&) x y)
|x <- [True,False],y <- [True,False]]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe