Next: srfi ilists procs selectors, Previous: srfi ilists procs constructors, Up: srfi ilists procs [Index]
These identifiers are bound either to the same procedure, or to procedures of equivalent behavior. In either case, true is returned if, and only if, x is a proper ilist a ‘()’–terminated ilist.
More specifically: the empty list is a proper ilist. An ipair whose icdr is a proper ilist is also a proper ilist. Everything else is a dotted ilist. This includes non–ipair, non–‘()’ values (e.g. symbols, numbers, mutable pairs), which are considered to be dotted ilists of length zero.
True if x is a finite, non–nil–terminated ilist. That is, there exists an ‘n >= 0’ such that ‘icdrn(x)’ is neither an ipair nor ‘()’. This includes non–ipair, non–‘()’ values (e.g. symbols, numbers), which are considered to be dotted ilists of length zero.
(dotted-ilist? x) ≡ (not (proper-ilist? x))
Return #t
if object is an ipair; otherwise #f
.
(ipair? (ipair 'a 'b)) ⇒ #t (ipair? (iq a b c)) ⇒ #t (ipair? (cons 1 2)) ⇒ #f (ipair? '()) ⇒ #f (ipair? '#(a b)) ⇒ #f (ipair? 7) ⇒ #f (ipair? 'a) ⇒ #f
ilist is a proper ilist. This procedure returns true if the
argument is the empty list ‘()’, and #f
otherwise. It is an
error to pass this procedure a value which is not a proper ilist. This
procedure is recommended as the termination condition for
ilist–processing procedures that are not defined on dotted ilists.
Equivalent to:
(lambda (x) (not (ipair? x)))
Provided as a procedure as it can be useful as the termination condition for ilist–processing procedures that wish to handle all ilists, both proper and dotted.
Determines ilist equality, given an element–equality procedure. Proper ilist A equals proper ilist B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element–comparison procedure’s first argument is from ilisti, then its second argument is from ilisti+1, i.e. it is always called as ‘(elt= a b)’ for a an element of ilist A, and b an element of ilist B.
In the n–ary case, every ilisti is compared to
ilisti+1 (as opposed, for example, to comparing ilist1 to
ilisti, for i>1). If there are no ilist arguments at
all, ilist=
simply returns #t
.
It is an error to apply ilist=
to anything except proper ilists.
It cannot reasonably be extended to dotted ilists, as it provides no way
to specify an equality procedure for comparing the ilist terminators.
Note that the dynamic order in which the elt= procedure is applied
to pairs of elements is not specified. For example, if ilist=
is
applied to three ilists, A, B, and C, it may first
completely compare A to B, then compare B to C,
or it may compare the first elements of A and B, then the
first elements of B and C, then the second elements of
A and B, and so forth.
The equality procedure must be consistent with eq?
. That is, it
must be the case that:
(eq? x y) ⇒ (elt= x y)
Note that this implies that two ilists which are eq?
are always
ilist=
, as well; implementations may exploit this fact to
“short–cut” the element–by–element comparisons.
(ilist= eq?) ⇒ #t ; trivial cases (ilist= eq? (iq a)) ⇒ #t
Next: srfi ilists procs selectors, Previous: srfi ilists procs constructors, Up: srfi ilists procs [Index]