chickadee » vector-lib » vector-unfold-right

vector-unfold-right f length initial-seed ···procedure

Like vector-unfold, but it uses f to generate elements from right-to-left, rather than left-to-right.

Examples:

Construct a vector in reverse of the integers in the range [0,n).

(vector-unfold-right (λ (i x) (values x (+ x 1)))
                     n 0)
  ;=> #(n-1 n-2 ··· 2 1 0)

Reverse vector.

(vector-unfold-right (λ (i x) (values (vector-ref vector x) (+ x 1)))
                     (vector-length vector) 0)