-
Notifications
You must be signed in to change notification settings - Fork 2
vector
TurtleKitty edited this page May 10, 2019
·
3 revisions
A vector is a contiguous array of values. A matrix is a vector composed of vectors.
(vector 1 2 3) ; #(vector 1 2 3)
(vector 1 2 3 size: 5) ; (vector: 1 2 3 null null)
(matrix 1 2 3) ; #(vector 1 2 3)
(matrix (1 2) (3 4)) ; #(vector #(vector 1 2) #(vector 3 4))
(def v (vector 1 2 3))
(def z (vector)) ; z is for zero elements
v.type ; (vector)
v.0 ; 1
(v 0) ; 1
v.2 ; 3
v.size ; 3
z.size ; 0
v.to-bool ; true
z.to-bool ; false
v.empty? ; false
z.empty? ; true
(v.has? 2) ; true
(v.has? 5) ; false
v.to-list ; (1 2 3)
v.to-set ; #(set (0 . 1) (2 . 3) (1 . 2))
v.to-table ; #(table 2 3 1 2 0 1)
v.clone ; #(vector 1 2 3)
v.pairs ; ((0 . 1) (1 . 2) (2 . 3))