Next: vectors fold, Previous: vectors pred, Up: vectors [Index]
Determine the mismatch index between the two subvectors: the largest index i such that for every 0 <= j < i, vec1[j] = vec2[j]; that is, i is the first position that does not match.
The mismatch index is always an index into vec1; in the case of equal vectors, it is always past1; the functions observe the protocol in this redundant case for uniformity.
The items before the mismatch index are tested for equality using item=; the items at the mismatch index are also compared using item<, to determine the smallest.
proc<, proc=, or proc> are applied to the mismatch index (not item), depending upon whether the subvector of vec1 is less than, equal to, or greater than the subvector of vec2. The result of the application is returned.
If we just want to have the mismatch index as return value: We can use
values
as value for proc<, proc= and proc>.
Another interesting option is to use (lambda (mismatch-index) #f)
or (lambda (mismatch-index) #t)
.
Examples:
(vector-compare '#(0 1 2 3) '#(0 1 2 3) values values values) ⇒ 4 (vector-compare '#(0 1 2 3) '#(0 1 2 3) values values values) ⇒ 4
Compare two subvectors: Return true if they are equal according to
item=, #f
otherwise.
Compare two subvectors: Return #f
if they are equal according to
item=, true otherwise.
The following predicates compare two subvectors according to the following rules:
Compare two subvectors: Return true if the first is less than the
second, #f
otherwise.
Compare two subvectors: Return true if the first is less than, or equal
to, the second; #f
otherwise.
Compare two subvectors: Return true if the first is greater than the
second, #f
otherwise.
Compare two subvectors: Return true if the first is greater than, or
equal to, the second; #f
otherwise.
Next: vectors fold, Previous: vectors pred, Up: vectors [Index]