
29 Jul
2004
29 Jul
'04
2:56 p.m.
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