Skip to content
TurtleKitty edited this page May 10, 2019 · 2 revisions

tuple

A tuple is a fixed set of named values.

constructor

(tuple 'foo 2 'bar 3 'baz 5)  ; #(tuple foo 2 bar 3 baz 5)

messages

(def empty (tuple))
(def point (tuple 'x 7 'y 11 'z 13))

point.type     ; (tuple)
point.x        ; 7
point.y        ; 11
point.z        ; 13

(point.add 't 17)    ; #(tuple x 7 y 11 z 13 t 17)
(point.del 'z)       ; #(tuple x 7 y 11)
point                ; #(tuple x 7 y 11 z 13)

empty.size     ; 0
empty.to-bool  ; false
point.size     ; 3
point.to-bool  ; true

point.fields   ; (z y x)
point.clone    ; #(tuple x 7 y 11 z 13)

; mutation

(point.y! 7)   ; 7
(point.z! 7)   ; 7
point          ; #(tuple x 7 y 7 z 7)
Clone this wiki locally