Next: , Previous: , Up: loops comprehensions   [Index]


1.16.2.4 Vector accumulator loops

Syntax: vector-ec ?qualifier ... expression

The vector of all values of expression. Think of it as:

(list->vector (list-ec ?qualifier ... expression))

Examples:

(vector-ec              ;no qualifiers
  1)
⇒ (vector 1)

(vector-ec (:range i 0)
  i)
⇒ (vector)

(vector-ec (:range i 1)
  i)
⇒ (vector 0)

(vector-ec (:range i 2)
  i)
⇒ (vector 0 1)
Syntax: vector-of-length-ec k ?qualifier ... expression

The vector of all values of expression, of which there must be exactly k. This comprehension behaves like vector-ec but can be implemented more efficiently.

(vector-of-length-ec 1
  1)
⇒ (vector 1)

(vector-of-length-ec 0 (:range i 0)
  i)
⇒ (vector)

(vector-of-length-ec 1 (:range i 1)
  i)
⇒ (vector 0)

(vector-of-length-ec 2 (:range i 2)
  i)
⇒ (vector 0 1)