Finished koan 13

This commit is contained in:
Matt Davidson 2022-11-05 10:27:48 +00:00
parent 2bd286b9aa
commit 0d83f43cfd

View file

@ -5,31 +5,29 @@
(meditations (meditations
"One may know what they seek by knowing what they do not seek" "One may know what they seek by knowing what they do not seek"
(= [__ __ __] (let [not-a-symbol? (complement symbol?)] (= [true false true] (let [not-a-symbol? (complement symbol?)]
(map not-a-symbol? [:a 'b "c"]))) (map not-a-symbol? [:a 'b "c"])))
"Praise and 'complement' may help you separate the wheat from the chaff" "Praise and 'complement' may help you separate the wheat from the chaff"
(= [:wheat "wheat" 'wheat] (= [:wheat "wheat" 'wheat]
(let [not-nil? ___] (let [not-nil? (complement nil?)]
(filter not-nil? [nil :wheat nil "wheat" nil 'wheat nil]))) (filter not-nil? [nil :wheat nil "wheat" nil 'wheat nil])))
"Partial functions allow procrastination" "Partial functions allow procrastination"
(= 20 (let [multiply-by-5 (partial * 5)] (= 20 (let [multiply-by-5 (partial * 5)] (multiply-by-5 4)))
(___ __)))
"Don't forget: first things first" "Don't forget: first things first"
(= [__ __ __ __] (= [:a :b :c :d]
(let [ab-adder (partial concat [:a :b])] (let [ab-adder (partial concat [:a :b])] (ab-adder [:c :d])))
(ab-adder [__ __])))
"Functions can join forces as one 'composed' function" "Functions can join forces as one 'composed' function"
(= 25 (let [inc-and-square (comp square inc)] (= 25 (let [inc-and-square (comp square inc)]
(inc-and-square __))) (inc-and-square 4)))
"Have a go on a double dec-er" "Have a go on a double dec-er"
(= __ (let [double-dec (comp dec dec)] (= 8 (let [double-dec (comp dec dec)]
(double-dec 10))) (double-dec 10)))
"Be careful about the order in which you mix your functions" "Be careful about the order in which you mix your functions"
(= 99 (let [square-and-dec ___] (= 99 (let [square-and-dec (comp dec square)]
(square-and-dec 10)))) (square-and-dec 10))))