On Wed, Dec 7, 2011 at 23:24, Alexej Segeda
<aloscha_den_st...@hotmail.com>wrote:

>                 case s of
>                    (s == reverse s)    -> putStrLn (s ++ " is a
> palindrome")
>                    otherwise           -> putStrLn (s ++ " is not a
> palindrome")
>

case does pattern matching, not Boolean expressions.  (s == reverse s) is
not a useful pattern, and in fact is probably a syntax error because == is
not a valid infix constructor.

If you want to do Boolean comparisons in a case, you need to use something
like

> case () of
>   () | s == reverse s -> putStrLn "palindrome"
>   _                   -> putStrLn "nope"

(otherwise isn't doing what you think there, either; it's exactly
equivalent to the _ (unnamed placeholder) I used, since you aren't then
using otherwise as the local binding (shadowing the Prelude one) that it
is.)

-- 
brandon s allbery                                      allber...@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to