On Sun, Feb 09, 2025 at 02:13:13PM -0800, Lindsay Lawrence wrote:
> 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?

Exactly. 'tco' does not make much difference in total running time. It
is all about stack usage.

Try with a limited stack size:

: (stack 8 8)  # Stack sizes 8 KiB
-> 8
: (co 'a (yield))  # Start a coroutine to segment the stack
-> NIL

: (fiboTco 99)
-> 218922995834555169026

: (fiboRecur 99)
!? ((N A B) (if (=0 N) A (recurse (dec N) B (+ A B))))
T -- Stack overflow
?
Give up: No stack

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to