[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
doc proper-list? etc
From: |
Kevin Ryde |
Subject: |
doc proper-list? etc |
Date: |
Thu, 27 Jan 2005 11:20:56 +1100 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux) |
I've tried to clarify proper-list? and friends a bit, in particular to
note how they partition all objects.
-- Scheme Procedure: proper-list? obj
Return `#t' if OBJ is a proper list, or `#f' otherwise. This is
the same as the core `list?' (*note List Predicates::).
A proper list is a list which ends with the empty list `()' in the
usual way. The empty list `()' itself is a proper list too.
(proper-list? '()) => #t
(proper-list? '(1 2 3)) => #t
-- Scheme Procedure: circular-list? obj
Return `#t' if OBJ is a circular list, or `#f' otherwise.
A circular list is a list where at some point the `cdr' refers
back to a previous pair in the list (either the start or some later
point), so that following the `cdr's takes you around in a circle,
with no end.
(define x (list 1 2 3 4))
(set-cdr! (last-pair x) (cddr x))
x => (1 2 3 4 3 4 3 4 ...)
(circular-list? x) => #t
-- Scheme Procedure: dotted-list? obj
Return `#t' if OBJ is a dotted list, or `#f' otherwise.
A dotted list is a list where the `cdr' of the last pair is not
the empty list `()'. Any non-pair OBJ is also considered a dotted
list, one with length zero.
(dotted-list? '(1 2 . 3)) => #t
(dotted-list? 99) => #t
It will be noted that any Scheme object passes exactly one of the
above three tests `proper-list?', `circular-list?' and `dotted-list?'.
Non-lists are `dotted-list?', finite lists are either `proper-list?' or
`dotted-list?', and infinite lists are `circular-list?'.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- doc proper-list? etc,
Kevin Ryde <=