[Haskell-beginners] if True than let...

John Melesky list at phaedrusdeinus.org
Thu Jun 25 16:24:53 EDT 2009


On Jun 25, 2009, at 1:12 PM, Bernhard Lehnert wrote:
> 1:     if a == True then putStrLn "Yes!" else putStrLn "No."
> 2:     if a == True then let b = "+" else let b = "-"

You can try:

let b = if a == True then "+" else "-"

Also, whenever you find yourself testing 'x == True' or 'x == False',  
you can reduce that to 'x' and 'not x' respectively, so you go down to:

let b = if a then "+" else "-"

Hope that helps.

-johnnnnnnn



More information about the Beginners mailing list