adding about sets
This commit is contained in:
parent
f536d91a91
commit
b2961f1fca
16
koans/about_sets.clj
Normal file
16
koans/about_sets.clj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
(meditations
|
||||||
|
"Sets are another important data structure in clojure"
|
||||||
|
(= #{} (set nil))
|
||||||
|
|
||||||
|
"Remember that a set is a 'set'"
|
||||||
|
(= __ (set '(1 1 2 2 3 3 4 4 5 5)))
|
||||||
|
|
||||||
|
"You can ask clojure for the union of two sets"
|
||||||
|
(= __ (clojure.set/union #{1 2 3 4} #{2 3 5}))
|
||||||
|
|
||||||
|
"And also the intersection"
|
||||||
|
(= __ (clojure.set/intersection #{1 2 3 4} #{2 3 5}))
|
||||||
|
|
||||||
|
"But don't forget about the difference"
|
||||||
|
(= __ (clojure.set/difference #{1 2 3 4 5} #{2 3 5})))
|
||||||
|
|
@ -14,4 +14,5 @@
|
|||||||
|
|
||||||
(load "about_equalities")
|
(load "about_equalities")
|
||||||
(load "about_vectors")
|
(load "about_vectors")
|
||||||
|
(load "about_sets")
|
||||||
(println "You have acheived clojure enlightenment. Namaste.")
|
(println "You have acheived clojure enlightenment. Namaste.")
|
Loading…
Reference in New Issue
Block a user