[Haskell-cafe] Why doesn't this work? (palindrome :: IO)

Yves Parès limestrael at gmail.com
Fri Dec 9 10:16:20 CET 2011


Why do you people hate 'if' statements?

2011/12/9 Brandon Allbery <allbery.b at gmail.com>

> On Thu, Dec 8, 2011 at 15:52, Tom Murphy <amindfv at gmail.com> wrote:
>
>> On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery <allbery.b at gmail.com>wrote:
>>
>>> > case () of
>>> >   () | s == reverse s -> putStrLn "palindrome"
>>> >   _                   -> putStrLn "nope"
>>>
>>
>>
>> This is kind of a hack of case, though. I think what the OP was looking
>> for is
>>
>  isPalindrome word
>
>>   | (word == reverse word) = putStrLn (word ++ " is a palindrome")
>>   | otherwise              = putStrLn (word ++ " is not a palindrome")
>>
>
> Erm?  It's as much of a hack of case as yours is, since the above is
> actually using case.
>
>
> --
> brandon s allbery                                      allbery.b at gmail.com
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111209/f29a79ed/attachment.htm>


More information about the Haskell-Cafe mailing list