[Haskell-beginners] parse error
Felipe Lessa
felipe.lessa at gmail.com
Sun Oct 4 10:35:55 EDT 2009
On Sun, Oct 04, 2009 at 04:11:35PM +0200, informationen wrote:
> the "| True" part is wrong. It should read:
>
> is_even n | n `mod` 2 == 0 = True
> | otherwise = False.
Which means that is_even may be expressed as
is_even n = n `mod` 2 == 0
Equivalently, in C the first code would be
int is_even(int n) {
if (n % 2 == 0)
return 1;
else
return 0;
}
while the code I presented above would be
int is_even(int n) {
return (n % 2 == 0);
}
HTH,
--
Felipe.
More information about the Beginners
mailing list