-
Notifications
You must be signed in to change notification settings - Fork 2
set
TurtleKitty edited this page May 10, 2019
·
1 revision
A set is an unordered collection of values without repitition.
(set 2 "three" 'five) ; #(set 2 "three" five)
(def s0 (set))
(def s1 (set 2 3 5 "hola" 'mundo))
(def s2 (set 3 5 7))
s1.type ; (set)
s0.size ; 0
s0.to-bool ; false
s1.size ; 5
s1.to-bool ; true
(s1.has? 2) ; true
(s1.has? 'mundo) ; true
(s1.has? 'world) ; false
(s1.union s2) ; #(set "hola" 5 7 2 3 mundo)
(s1.intersect s2) ; #(set 5 3)
(s1.diff s2) ; #(set mundo "hola" 2)
(s2.diff s1) ; #(set 7)
(s1.xor s2) ; #(set "hola" mundo 7 2)
(s2.add 9) ; #(set 3 5 7 9)
(s2.del 3) ; #(set 5 7)
s2 ; #(set 3 5 7)
; mutation
(s2.add! 9) ; #(set 9 7 5 3)
s2 ; #(set 9 7 5 3)
(s2.del! 3) ; #(set 9 7 5)
s2 ; #(set 9 7 5)