Re: How do I distinguish a list from cons pair?

2025-02-12 Thread Lindsay Lawrence
On Tue, Feb 11, 2025 at 11:38 PM Alexander Burger wrote: > I would say it is a cell with a non-NIL and non-atomic CDR, then (1 . 2) > is not a list but > >(1 . NIL) # (1) > > or > >(1 . (2 . NIL)) # (1 2) > > is. > > 👍 BTW, 'fin' can be used to distinguish them: > >: (fin (1 2)) >

Re: Tail call optimization

2025-02-12 Thread Alexander Burger
Oops, sorry! Yesterday evening I noticed that I messed it up, but was too tired to dig into it. On Wed, Feb 12, 2025 at 02:28:25PM -0800, Lindsay Lawrence wrote: > Question: Without fully understanding the algorithm, it seems N is the next > digit to return... Right. I posted the original 'whil

Re: Tail call optimization

2025-02-12 Thread Lindsay Lawrence
On Tue, Feb 11, 2025 at 11:25 PM Alexander Burger wrote: > > If a problem is a linear operation, like traversing a list, a loop is > more natural for me. For traversing a tree, recursion is better of > course. > > Thanks! >(de fiboSwap (N) > (let (A 0 B 1) > (do N >

Re: Tail call optimization

2025-02-12 Thread Alexander Burger
On Wed, Feb 12, 2025 at 08:14:04AM +0100, Alexander Burger wrote: > If a problem is a linear operation, like traversing a list, a loop is > more natural for me. For traversing a tree, recursion is better of > course. Hmm, it seems that I begin to detect some advantages in tco/tc :) For example, i

Re: Tail call optimization

2025-02-12 Thread Lindsay Lawrence
> Hmm, it seems that I begin to detect some advantages in tco/tc :) > > For example, in pil64 I had a function calculating the digits of pi ad > infinitum: > ># Print next digit of PI >(de piDigit () > (job '((Q . 1) (R . 0) (S . 1) (K . 1) (N . 3) (L . 3)) > (while (>= (- (+