On Tue, Feb 11, 2025 at 10:16:14PM -0800, Lindsay Lawrence wrote:
> Is there a way to distinguish a list from a cons pair?
> 
> The 'pair' function does not seem to do what I want.

It depends on how you define a list.

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.

I would also call

   (1 . (2 . 3))  # (1 2 . 3)

a list.

BTW, 'fin' can be used to distinguish them:

   : (fin (1 2))
   -> NIL
   : (fin (1 2 . 3))
   -> 3


> I would like to be able to distinguish the cons pair structure from 'list'

So perhaps

   : (lst? (cdr Pair))

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to