
Am Sonntag 20 Dezember 2009 21:06:36 schrieb kane96@gmx.de:
So,
toEnum n | n < 0 = Z toEnum 0 = Z toEnum n = ? -- here, we know n > 0
fromEnum should be the correspondnece the other way round, so
fromEnum Z = 0 fromEnum (S p) = ? -- which Int corresponds to the successor of p?
what is P?
Any element of Nat (p for Peano).
Now I read some short textes about it and think I know more or less what I have to do for the exercise. But I don't know really how. Do you know any examples for it, how it normally looks like?
Deniz Dogan posted a few links to recursion earlier today, if you look at them, you should get the general idea. As a further example, replicate :: Int -> a -> [a] replicate n x | n <= 0 = [] | otherwise = x:replicate (n-1) x may help.