vector-of creates a persistent vector whose elements are stored as a selected primitive type, reducing memory use when primitive storage fits the problem. Supply one of :int, :long, :float, :double, :byte, :short, :char, or :boolean; values must be coercible to that type. section 12.7
Listing 12.4. → Persistent Data Type, Primitives, Memory Efficient Storage
(vector-of ([t]) ([t x1]) ([t x1 x2]) ([t x1 x2 x3]) ([t x1 x2 x3 x4]) ([t x1 x2 x3 x4 & xn]))
The arity listing shows the empty-vector form, fixed argument forms, and the variadic form. section 12.7
Coercion and vector behavior
(vector-of :int 16/5 2.8 1M Double/NaN) ;; [3 2 1 0] ((vector-of :int 1 2 3) 2) ;; 3 (vector-of :int) ;; [] section 12.7
Account for these constraints:
- Reject nil because primitive vectors cannot contain it, whether during construction or conj. section 12.7
- Expect failures for invalid type specifications, incompatible coercions, and out-of-range values. section 12.7
- Use it for dense numerical data such as Mandelbrot-set points containing real, imaginary, and iteration values. section 12.7
