>
>
> It is interesting that I don't see much performance difference between tco
> and recur in most cases.
> Perhaps the primary difference is their resource usage?
>
> For example, using (mike)'s fibo example.... and simply replacing tco with
> recur (see code at end)
> I initially expected (fiboRecur) to have a similar bench profile to (fibo).
>
>
Thinking about this a bit more a bit more, and rewriting the first fibo
function in the style of tco and recur
(de fibo2 (N A B)
(default A 0 B 1)
(if (=0 N)
A
(fibo2 (dec N) B (+ A B)) ) )
We get
: (bench (fibo2 37))
0.000 sec
-> 24157817
Which is on par with tco and recur.
/Lindsay
: (bench (fibo 37))
> 2.779 sec
> -> 24157817
> : (bench (fiboRecur 37))
> 0.000 sec
> -> 24157817
> : (bench (fiboTco 37))
> 0.000 sec
> -> 24157817
>
> # The functions used
>
> (de fibo (N)
> (if (>= 2 N)
> 1
> (+ (fibo (dec N)) (fibo (- N 2))) ) )
>
> (de fiboTco (N)
> (let (A 0 B 1)
> (tco (N A B)
> (if (=0 N)
> A
> (tc (dec N) B (+ A B)) ) ) ) )
>
> (de fiboRecur (N)
> (let (A 0 B 1)
> (recur (N A B)
> (if (=0 N)
> A
> (recurse (dec N) B (+ A B)) ) ) ) )
>
>
>
>