kane96 at gmx.de kane96 at gmx.de
Sun Dec 20 15:35:45 EST 2009

```-------- Original-Nachricht --------
> Datum: Sun, 20 Dec 2009 21:28:21 +0100
> Von: Daniel Fischer <daniel.is.fischer at web.de>
> Betreff: Re: [Haskell-beginners] Enum for natural numbers

> Am Sonntag 20 Dezember 2009 21:06:36 schrieb kane96 at 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.

my problem is that I don't know how to use Enum correctly and didn't find any helpfull example

> _______________________________________________
> Beginners mailing list