From ddf1d2439dbf2b3913b15cb0776ac3fb782fd138 Mon Sep 17 00:00:00 2001 From: Kenneth Kostresevic Date: Thu, 16 Dec 2021 14:30:34 +0100 Subject: [PATCH 1/2] Solve creating functions --- src/koans/13_creating_functions.clj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/koans/13_creating_functions.clj b/src/koans/13_creating_functions.clj index 7d84bc8..ff7203c 100644 --- a/src/koans/13_creating_functions.clj +++ b/src/koans/13_creating_functions.clj @@ -5,31 +5,31 @@ (meditations "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"]))) "Praise and 'complement' may help you separate the wheat from the chaff" (= [:wheat "wheat" 'wheat] - (let [not-nil? ___] + (let [not-nil? (complement nil?)] (filter not-nil? [nil :wheat nil "wheat" nil 'wheat nil]))) "Partial functions allow procrastination" (= 20 (let [multiply-by-5 (partial * 5)] - (___ __))) + (reduce multiply-by-5 2 '(2)))) "Don't forget: first things first" - (= [__ __ __ __] + (= [:a :b :c :d] (let [ab-adder (partial concat [:a :b])] - (ab-adder [__ __]))) + (ab-adder [:c :d]))) "Functions can join forces as one 'composed' function" (= 25 (let [inc-and-square (comp square inc)] - (inc-and-square __))) + (inc-and-square 4))) "Have a go on a double dec-er" - (= __ (let [double-dec (comp dec dec)] + (= 8 (let [double-dec (comp dec dec)] (double-dec 10))) "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)))) From 170cc2cd0d7f61e46c207529ee675b2cb5c8fafc Mon Sep 17 00:00:00 2001 From: Kenneth Kostresevic Date: Thu, 16 Dec 2021 16:26:40 +0100 Subject: [PATCH 2/2] Simplify function call --- src/koans/13_creating_functions.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/koans/13_creating_functions.clj b/src/koans/13_creating_functions.clj index ff7203c..35910bd 100644 --- a/src/koans/13_creating_functions.clj +++ b/src/koans/13_creating_functions.clj @@ -15,7 +15,7 @@ "Partial functions allow procrastination" (= 20 (let [multiply-by-5 (partial * 5)] - (reduce multiply-by-5 2 '(2)))) + (multiply-by-5 4))) "Don't forget: first things first" (= [:a :b :c :d]