On Mon, Feb 10, 2025 at 2:49 AM Alexander Burger <picolisp@software-lab.de> wrote:
> > I'd like to point out, however, that recursion and tail call > optimization are not fully equivalent. We always need to keep that in > mind! > > The original idea of TCO (not the 'tco' function in PicoLisp) is to > avoid that calling the very last function in a function does > > ... > PicoLisp is an interpreter, and performing such code modifications would > be extremely inefficient. > > But for PicoLisp (I think Scheme doesn't even address such issues), > there are also other implications. The above example has the call to 'f' > only in the body of a single 'if' expression. But what if you have more > complicated nestings? > > ... Thanks Alex. I appreciate the insight into picolisp's tco given here. 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 /Lindsay