[Haskell-beginners] Enum for natural numbers

kane96 at gmx.de kane96 at gmx.de
Mon Dec 21 16:40:54 EST 2009


-------- Original-Nachricht --------
> Datum: Mon, 21 Dec 2009 22:06:46 +0100
> Von: Daniel Fischer <daniel.is.fischer at web.de>
> An: beginners at haskell.org
> CC: kane96 at gmx.de, jean verdier <verdier.jean at gmail.com>
> Betreff: Re: [Haskell-beginners] Enum for natural numbers

> Am Montag 21 Dezember 2009 21:02:06 schrieb kane96 at gmx.de:
> > > your type is
> > > data Nat = S Nat | Z
> > > and not
> > > data Nat = 1 + Nat | 0
> >
> > Do I have to use something like fromEnum (S Z)? Or or the iteration
> wrong?
> 
> Which operation on Nat corresponds to (1 +) on Int[eger] ?

I implemented it:
allNats :: [Nat]
allNats = iterate S Z


-- 
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
http://portal.gmx.net/de/go/dsl02


More information about the Beginners mailing list