- 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. The first index used is length - 1. Note that the termination condition is different from the unfold-right procedure of SRFI 1.
Examples:
Construct a vector of pairs of non-negative integers whose values sum to 4.
(vector-unfold-right (lambda (i x) (values (cons i x) (+ x 1))) 5 0) ;=> #((0 . 4) (1 . 3) (2 . 2) (3 . 1) (4 . 0))
Reverse vector.
(vector-unfold-right (lambda (i x) (values (vector-ref vector x) (+ x 1))) (vector-length vector) 0)