Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.
Next: SRFI-43 Mutators, Previous: SRFI-43 Iteration, Up: SRFI-43 [Contents][Index]
Find and return the index of the first elements in vec1 vec2
… that satisfy pred?. If no matching element is found by
the end of the shortest vector, return #f
.
(vector-index even? '#(3 1 4 1 5 9)) ⇒ 2 (vector-index < '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2)) ⇒ 1 (vector-index = '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2)) ⇒ #f
Like vector-index
, but it searches right-to-left, rather than
left-to-right. Note that the SRFI 43 specification requires that all
the vectors must have the same length, but both the SRFI 43 reference
implementation and Guile’s implementation allow vectors with unequal
lengths, and start searching from the last index of the shortest vector.
Find and return the index of the first elements in vec1 vec2
… that do not satisfy pred?. If no matching element is
found by the end of the shortest vector, return #f
. Equivalent
to vector-index
but with the predicate inverted.
(vector-skip number? '#(1 2 a b 3 4 c d)) ⇒ 2
Like vector-skip
, but it searches for a non-matching element
right-to-left, rather than left-to-right. Note that the SRFI 43
specification requires that all the vectors must have the same length,
but both the SRFI 43 reference implementation and Guile’s implementation
allow vectors with unequal lengths, and start searching from the last
index of the shortest vector.
Find and return an index of vec between start and end
whose value is value using a binary search. If no matching
element is found, return #f
. The default start is 0 and
the default end is the length of vec.
cmp must be a procedure of two arguments such that (cmp a
b)
returns a negative integer if a < b, a positive integer if
a > b, or zero if a = b. The elements of vec must
be sorted in non-decreasing order according to cmp.
Note that SRFI 43 does not document the start and end arguments, but both its reference implementation and Guile’s implementation support them.
(define (char-cmp c1 c2) (cond ((char<? c1 c2) -1) ((char>? c1 c2) 1) (else 0))) (vector-binary-search '#(#\a #\b #\c #\d #\e #\f #\g #\h) #\g char-cmp) ⇒ 6
Find the first parallel set of elements from vec1 vec2
… for which pred? returns a true value. If such a parallel
set of elements exists, vector-any
returns the value that
pred? returned for that set of elements. The iteration is
strictly left-to-right.
If, for every index i between 0 and the length of the shortest vector
argument, the set of elements (vector-ref vec1 i)
(vector-ref vec2 i)
… satisfies pred?,
vector-every
returns the value that pred? returned for the
last set of elements, at the last index of the shortest vector.
Otherwise it returns #f
. The iteration is strictly
left-to-right.
Next: SRFI-43 Mutators, Previous: SRFI-43 Iteration, Up: SRFI-43 [Contents][Index]