chickadee » srfi-133 » vector=

vector= elt=? vec ...procedure

Vector structure comparator, generalized across user-specified element comparators. Vectors a and b are considered equal by vector= iff their lengths are the same, and for each respective element Ea and Eb, (elt=? Ea Eb) returns a true value. elt=? is always applied to two arguments. Element comparison must be consistent with eq; that is, if (eq? Ea Eb) results in a true value, then (elt=? Ea Eb) must also result in a true value. This may be exploited to avoid unnecessary element comparisons. (The reference implementation does, but it does not consider the situation where elt=? is in fact itself eq? to avoid yet more unnecessary comparisons.)

If there are only zero or one vector arguments, #t is automatically returned. The dynamic order in which comparisons of elements and of vectors are performed is left completely unspecified; do not rely on a particular order.


(vector= eq? '#(a b c d) '#(a b c d)) ;=> #t
(vector= eq? '#(a b c d) '#(a b d c)) ;=> #f
(vector= = '#(1 2 3 4 5) '#(1 2 3 4)) ;=> #f
(vector= = '#(1 2 3 4) '#(1 2 3 4))   ;=> #t

The two trivial cases.

(vector= eq?) ;=> #t
(vector= eq? '#(a)) ;=> #t

Note the fact that we don't use vector literals in the next two -- it is unspecified whether or not literal vectors with the same external representation are eq?.

(vector= eq? (vector (vector 'a)) (vector (vector 'a)))
 ;=> #f
(vector= equal? (vector (vector 'a)) (vector (vector 'a)))
 ;=> #t