Hey, I'm curious myself honestly.
Lists are kind of a virtual type, it's just a bunch of cons cells in a sequencial pattern. I think you'd need to write your own function that walks the list to see if its proper or improper (ends with non-nil). Best regards, Geri On Wed, Feb 12, 2025, 08:28 Lindsay Lawrence <picolisp@software-lab.de> wrote: > Is there a way to distinguish a list from a cons pair? > > The 'pair' function does not seem to do what I want. > > : (pair (cons 1 2)) > -> (1 . 2) > : (pair (list 1 2)) > -> (1 2) > : (pair (list 1 (2 3))) > -> (1 (2 3)) > : (pair (cons 1 (2 3))) > -> (1 2 3) > > I would like to be able to distinguish the cons pair structure from 'list' > > /Lindsay > > : (view (cons 1 2)) > +-- 1 > | > 2 > > : (view (list 1 2)) > +-- 1 > | > +-- 2 > > : (view (cons 1 (2 3))) > +-- 1 > | > +-- 2 > | > +-- 3 > > : (view (list 1 (2 3))) > +-- 1 > | > +---+-- 2 > | > +-- 3 > >>