[Haskell-cafe] why is Prelude.^ so convoluted?

Ronny Wichers Schreur ronny at cs.kun.nl
Thu Jul 29 14:56:10 EDT 2004


Brandon Beck wrote:

> [..] I suspect the justification is because the version in the
> prelude is tail recursive while yours isn't. 

It also performs fewer negativity and zero tests and it builds
fewer closures.

> So the tail recursive version should run a bit faster when n
> is large.

 From the intro of the Haskell'98 prelude
<http://www.haskell.org/onlinereport/standard-prelude.html>:

    "It constitutes a specification for the Prelude. Many of the
     definitions are written with clarity rather than efficiency
     in mind"

The power function is not an example of this.


Cheers,

Ronny Wichers Schreur


More information about the Haskell-Cafe mailing list