sets done

This commit is contained in:
Oli Clive-Griffin 2021-06-03 13:49:54 +12:00
parent 9ea2e0473c
commit 5b234f8edf

View file

@ -4,19 +4,19 @@
(meditations (meditations
"You can create a set by converting another collection" "You can create a set by converting another collection"
(= #{3} (set __)) (= #{3} (set '(3)))
"Counting them is like counting other collections" "Counting them is like counting other collections"
(= __ (count #{1 2 3})) (= 3 (count #{1 2 3}))
"Remember that a set is a *mathematical* set" "Remember that a set is a *mathematical* set"
(= __ (set '(1 1 2 2 3 3 4 4 5 5))) (= #{1 2 3 4 5} (set '(1 1 2 2 3 3 4 4 5 5)))
"You can ask clojure for the union of two sets" "You can ask clojure for the union of two sets"
(= __ (set/union #{1 2 3 4} #{2 3 5})) (= #{1 2 3 4 5} (set/union #{1 2 3 4} #{2 3 5}))
"And also the intersection" "And also the intersection"
(= __ (set/intersection #{1 2 3 4} #{2 3 5})) (= #{2 3} (set/intersection #{1 2 3 4} #{2 3 5}))
"But don't forget about the difference" "But don't forget about the difference"
(= __ (set/difference #{1 2 3 4 5} #{2 3 5}))) (= #{1 4} (set/difference #{1 2 3 4 5} #{2 3 5})))