Next: Cutting and Pasting Lists, Previous: Construction of Lists, Up: Lists
Returns
#t
if object is a list, otherwise returns#f
. By definition, all lists have finite length and are terminated by the empty list. This procedure returns an answer even for circular structures.Any object satisfying this predicate will also satisfy exactly one of
pair?
ornull?
.(list? '(a b c)) => #t (list? '()) => #t (list? '(a . b)) => #f (let ((x (list 'a))) (set-cdr! x x) (list? x)) => #f
(SRFI 1) Returns
#t
if object is a circular list, otherwise returns#f
.(dotted-list? (list 'a 'b 'c)) => #f (dotted-list? (cons* 'a 'b 'c)) => #t (dotted-list? (circular-list 'a 'b 'c)) => #f
(SRFI 1) Returns
#t
if object is an improper list, otherwise returns#f
.(circular-list? (list 'a 'b 'c)) => #f (circular-list? (cons* 'a 'b 'c)) => #f (circular-list? (circular-list 'a 'b 'c)) => #t
Returns the length of list. Signals an error if list isn't a proper list.
(length '(a b c)) => 3 (length '(a (b) (c d e))) => 3 (length '()) => 0 (length (circular-list 'a 'b 'c)) error-->
(SRFI 1) Returns the length of clist, if it is a proper list. Returns
#f
if clist is a circular list. Otherwise signals an error.(length+ (list 'a 'b 'c)) => 3 (length+ (cons* 'a 'b 'c)) error--> (length+ (circular-list 'a 'b 'c)) => #f
Returns
#t
if object is the empty list; otherwise returns#f
.(null? '(a . b)) => #f (null? '(a b c)) => #f (null? '()) => #t
Returns the kth element of list, using zero-origin indexing. The valid indexes of a list are the exact non-negative integers less than the length of the list. The first element of a list has index
0
, the second has index1
, and so on.(list-ref '(a b c d) 2) => c (list-ref '(a b c d) (inexact->exact (round 1.8))) => c
(list-ref
list k)
is equivalent to(car (list-tail
list k))
.
Returns the specified element of list. It is an error if list is not long enough to contain the specified element (for example, if the argument to
seventh
is a list that contains only six elements).