chickadee » srfi-1 » list=

list= elt= list_1 ...procedure

Determines list equality, given an element-equality procedure. Proper list A equals proper list 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 LIST_I, then its second argument is from LIST_I+1, i.e. it is always called as (ELT= A B) for A an element of list A, and B an element of list B.

In the N-ary case, every LIST_I is compared to LIST_I+1 (as opposed, for example, to comparing LIST_1 to every LIST_I, for I>1). If there are no list arguments at all, list= simply returns true.

It is an error to apply list= to anything except proper lists. While implementations may choose to extend it to circular lists, note that it cannot reasonably be extended to dotted lists, as it provides no way to specify an equality procedure for comparing the list terminators.

Note that the dynamic order in which the ELT= procedure is applied to pairs of elements is not specified. For example, if list= is applied to three lists, 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 lists which are eq? are always LIST=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.

(list= eq?) => #t       ; Trivial cases
(list= eq? '(a)) => #t