Arc Forumnew | comments | leaders | submitlogin
3 points by cchooper 6096 days ago | link | parent

Here are my results:

non-recursive: 13469 13610 13480 13098 13139 avg. 13360

recursive: 13199 13279 13249 13340 13329 avg. 13279

I also tried a tail-recursive version, which should be faster than simple recursive:

  (def power (nbr pow (o retval 1))
    (if (is pow 0)
            retval
        (> pow 0)
            (power nbr (- pow 1) (* nbr retval))
        (< pow 0)
            (power nbr (+ pow 1) (/ retval nbr))))
and I got this:

13450 13449 13449 12938 13139 avg. 13285

So it looks to me like MzScheme can optimise them all to be about equal.

Edit: actually, as Sacado pointed out, Arc expands for into a recursive function, so we're not really testing iteration.