
4 Oct
2009
4 Oct
'09
10:35 a.m.
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.