[Haskell-cafe] Natural Numbers: Best implementation?

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Fri Mar 13 04:23:03 EDT 2009


Am Freitag, 13. März 2009 04:01 schrieb Alexander Dunlap:
> > 2.  Use the type
> >
> > data Natural = Zero | Succ !Natural
>
> […]
>
> In terms of speed, I think that [3] would be reasonably fast (unless
> you do a ton of subtraction with bounds-checking) and [2] would
> probably be quite slow, because you don't get the speed-boost from
> doing computations right on the processor.

Not only that but also because operations like addition now take at least 
linear time.

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list