Next: , Previous: , Up: srfi vector spec   [Index]


2.23.4.3 Predicates

Function: vector? x -> boolean

R5RS Disjoint type predicate for vectors: return #t if x is a vector, and #f otherwise.

Examples:

(vector? '#(a b c))
=> #t

(vector? '(a b c))
=> #f

(vector? #t)
=> #f

(vector? '#())
=> #t

(vector? '())
=> #f
Function: vector-empty? vec -> boolean

Return #t if vec is empty, i.e. its length is 0, otherwise #f.

Examples:

(vector-empty? '#(a))
=> #f

(vector-empty? '#(()))
=> #f

(vector-empty? '#(#()))
=> #f

(vector-empty? '#())
=> #t
Function: vector= elt=? vec ... -> boolean

Vector structure comparator, generalized across user–specified element comparators. Vectors a and b are considered equal by vector= if, and only if, their lengths are the same, and for each respective elements 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.

Examples:

(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

Next: , Previous: , Up: srfi vector spec   [Index]