
21 Dec
2009
21 Dec
'09
5:28 a.m.
Am Montag 21 Dezember 2009 10:56:06 schrieb kane96@gmx.de:
Now everything works but to print Z also for negative Integers. Don't know how to implement the <=0 or le0 in this case again:
instance Enum Nat where toEnum 0 = Z toEnum (n+1) = S(toEnum n)
Note that many frown upon (n+k)-patterns and they may be removed from the language in future. Use guards: toEnum n | condition1 = rhs1 | condition2 = rhs2
fromEnum Z = 0 fromEnum (S n) = 1 + fromEnum n