On Tue, Feb 11, 2025 at 11:38 PM Alexander Burger <picolisp@software-lab.de>
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))
>    -> NIL
>    : (fin (1 2 . 3))
>    -> 3
>
> 'fin' may be the function I am looking for. I will have to play with it a
bit and probably rethink my data structure.
I was trying to 'rotate' a tree structure and for the purpose of 'set' I
needed to distinguish between

(1 . 2)
(1 2)
(1 . (2 3 4))
(1 (2 3 4))

In the case of the pair, I can't use 'set' to update the cdr and would have
to use 'con' and reference the appropriate node.

   : (lst? (cdr Pair))
>

I tried that expression, but the way I was thinking about lists, and trying
to use them, didn't give me the results I expected.

: (lst? (cdr (1 . 2)))
-> NIL
: (lst? (cdr (1 2)))
-> T
: (lst? (cdr (1 . (2 3 4))))
-> T
: (lst? (cdr (1 (2 3 4))))
-> T

/Lindsay

Reply via email to