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


7.5.30.1 SRFI-43 Constructors

Scheme Procedure: make-vector size [fill]

Create and return a vector of size size, optionally filling it with fill. The default value of fill is unspecified.

(make-vector 5 3) ⇒ #(3 3 3 3 3)
Scheme Procedure: vector x …

Create and return a vector whose elements are x ....

(vector 0 1 2 3 4) ⇒ #(0 1 2 3 4)
Scheme Procedure: vector-unfold f length initial-seed …

The fundamental vector constructor. Create a vector whose length is length and iterates across each index k from 0 up to length - 1, applying f at each iteration to the current index and current seeds, in that order, to receive n + 1 values: the element to put in the kth slot of the new vector, and n new seeds for the next iteration. It is an error for the number of seeds to vary between iterations.

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

(vector-unfold values 10)
⇒ #(0 1 2 3 4 5 6 7 8 9)
Scheme Procedure: vector-unfold-right f length initial-seed …

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

(vector-unfold-right (lambda (i x) (values x (+ x 1)))
                     10 0)
⇒ #(9 8 7 6 5 4 3 2 1 0)
Scheme Procedure: vector-copy vec [start [end [fill]]]

Allocate a new vector whose length is end - start and fills it with elements from vec, taking elements from vec starting at index start and stopping at index end. start defaults to 0 and end defaults to the value of (vector-length vec). If end extends beyond the length of vec, the slots in the new vector that obviously cannot be filled by elements from vec are filled with fill, whose default value is unspecified.

(vector-copy '#(a b c d e f g h i))
⇒ #(a b c d e f g h i)

(vector-copy '#(a b c d e f g h i) 6)
⇒ #(g h i)

(vector-copy '#(a b c d e f g h i) 3 6)
⇒ #(d e f)

(vector-copy '#(a b c d e f g h i) 6 12 'x)
⇒ #(g h i x x x)
Scheme Procedure: vector-reverse-copy vec [start [end]]

Like vector-copy, but it copies the elements in the reverse order from vec.

(vector-reverse-copy '#(5 4 3 2 1 0) 1 5)
⇒ #(1 2 3 4)
Scheme Procedure: vector-append vec …

Return a newly allocated vector that contains all elements in order from the subsequent locations in vec ....

(vector-append '#(a) '#(b c d))
⇒ #(a b c d)
Scheme Procedure: vector-concatenate list-of-vectors

Append each vector in list-of-vectors. Equivalent to (apply vector-append list-of-vectors).

(vector-concatenate '(#(a b) #(c d)))
⇒ #(a b c d)

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