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: , Previous: , Up: SRFI-43   [Contents][Index]

#### 7.5.30.4 SRFI-43 Iteration

Scheme Procedure: vector-fold kons knil vec1 vec2 …

The fundamental vector iterator. kons is iterated over each index in all of the vectors, stopping at the end of the shortest; kons is applied as

```(kons i state (vector-ref vec1 i) (vector-ref vec2 i) ...)
```

where state is the current state value, and i is the current index. The current state value begins with knil, and becomes whatever kons returned at the respective iteration. The iteration is strictly left-to-right.

Scheme Procedure: vector-fold-right kons knil vec1 vec2 …

Similar to `vector-fold`, but it iterates right-to-left instead of left-to-right.

Scheme Procedure: vector-map f vec1 vec2 …

Return a new vector of the shortest size of the vector arguments. Each element at index i of the new vector is mapped from the old vectors by

```(f i (vector-ref vec1 i) (vector-ref vec2 i) ...)
```

The dynamic order of application of f is unspecified.

Scheme Procedure: vector-map! f vec1 vec2 …

Similar to `vector-map`, but rather than mapping the new elements into a new vector, the new mapped elements are destructively inserted into vec1. The dynamic order of application of f is unspecified.

Scheme Procedure: vector-for-each f vec1 vec2 …

Call `(f i (vector-ref vec1 i) (vector-ref vec2 i) ...)` for each index i less than the length of the shortest vector passed. The iteration is strictly left-to-right.

Scheme Procedure: vector-count pred? vec1 vec2 …

Count the number of parallel elements in the vectors that satisfy pred?, which is applied, for each index i less than the length of the smallest vector, to i and each parallel element in the vectors at that index, in order.

```(vector-count (lambda (i elt) (even? elt))
'#(3 1 4 1 5 9 2 5 6))
⇒ 3
(vector-count (lambda (i x y) (< x y))
'#(1 3 6 9) '#(2 4 6 8 10 12))
⇒ 2
```

Next: , Previous: , Up: SRFI-43   [Contents][Index]