On Mon, Feb 10, 2025 at 10:18:41PM -0800, Lindsay Lawrence wrote:
> I realized several existing recursive functions I use were trivially
> convertible and are now able to work with much larger lists.
>
> I put a few examples here: swap, mtf (move to front), mft (move from top)
>
> https://github.com/thinknlive/picolisp-lisp-basics/blob/master/tco.l
Thanks! It is very interesting for me to see TCO in such elaborated
examples. I usually approach such tasks with loops, with a rather
different mental model.
Concerning swap, we could for completeness mention that there is also
the built-in 'xchg' function:
: (let L (1 2 3 4 5 6 7)
(xchg (nth L 3) (nth L 5))
L )
-> (1 2 5 4 3 6 7)
☺/ A!ex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe