vector-unfold-right

[procedure] vector-unfold f length seed ...

[procedure] vector-unfold-right f length seed ...

SRFI-43: Create a vector of length length. Its elements are generated by calling f with the index and seed value(s); f should return 1 + number-of-seeds values; the first value is used for initializing the vector, and the rest is used for the seed values of the next call to f.

vector-unfold calls f to generate elements from index 0 to length-1. vector-unfold-right calls f to generate elements from length-1 to 0.

(vector-unfold (lambda (i x) (values x (- x 1))) 10 0) 
  =>  #(0 -1 -2 -3 -4 -5 -6 -7 -8 -9) 

(vector-unfold-right (lambda (i x) (values x (+ x 1))) 10 0) 
  =>  #(9 8 7 6 5 4 3 2 1 0)

See also unfold, unfold-right.