On Sun, Feb 9, 2025 at 11:18 PM Alexander Burger <picolisp@software-lab.de>
wrote:

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


> 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
>
>
Nice example.

'stack' is yet another function I haven't fully appreciated until recently

/Lindsay

Reply via email to