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

>

Reply via email to