From 3cca560b96369a96c5f021f86bf4977b858a40b9 Mon Sep 17 00:00:00 2001 From: Aaron Bedra Date: Tue, 25 Oct 2011 22:55:54 -0400 Subject: [PATCH] Reformatting for consistency --- src/koans/atoms.clj | 3 +-- src/koans/conditionals.clj | 17 ++++++++--------- src/koans/creating_functions.clj | 12 +++++------- src/koans/datatypes.clj | 1 - src/koans/destructuring.clj | 13 ++++++------- src/koans/functions.clj | 6 +++--- src/koans/macros.clj | 18 ++++++++---------- src/koans/maps.clj | 1 - src/koans/recursion.clj | 8 ++++---- src/koans/refs.clj | 21 ++++++++++----------- src/koans/sequence_comprehensions.clj | 4 ++-- src/koans/sets.clj | 1 - 12 files changed, 47 insertions(+), 58 deletions(-) diff --git a/src/koans/atoms.clj b/src/koans/atoms.clj index dbadb66b0..606629f43 100644 --- a/src/koans/atoms.clj +++ b/src/koans/atoms.clj @@ -27,5 +27,4 @@ "When your expectations are aligned with reality things, proceed that way" (= :fin (do (compare-and-set! __ __ __) - @atomic-clock)) - ) + @atomic-clock))) diff --git a/src/koans/conditionals.clj b/src/koans/conditionals.clj index da8b7079e..eaf571107 100644 --- a/src/koans/conditionals.clj +++ b/src/koans/conditionals.clj @@ -10,21 +10,21 @@ (meditations "You will face many decisions" (= __ (if (false? (= 4 5)) - :a - :b)) + :a + :b)) "Some of them leave you no alternative" (= __ (if (> 4 3) - [])) + [])) "And in such a situation you may have nothing" (= __ (if (nil? 0) - [:a :b :c])) + [:a :b :c])) "In others your alternative may be interesting" (= :glory (if (not (empty? ())) - :doom - __)) + :doom + __)) "You may have a multitude of possible paths" (let [x 5] @@ -34,8 +34,8 @@ "Or your fate may be sealed" (= __ (if-not (zero? __) - 'doom - 'doom)) + 'doom + 'doom)) "In case of emergency, sound the alarms" (= :sirens @@ -44,4 +44,3 @@ "But admit it when you don't know what to do" (= __ (explain-defcon-level :yo-mama))) - diff --git a/src/koans/creating_functions.clj b/src/koans/creating_functions.clj index b6b143c02..84ff21e5c 100644 --- a/src/koans/creating_functions.clj +++ b/src/koans/creating_functions.clj @@ -1,15 +1,14 @@ (defn square [x] (* x x)) (meditations - "One may know what they seek by knowing what they do not seek" (= [__ __ __] (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? ___] - (filter not-nil? [nil :wheat nil "wheat" nil 'wheat nil]))) + (let [not-nil? ___] + (filter not-nil? [nil :wheat nil "wheat" nil 'wheat nil]))) "Partial functions allow procrastination" (= 20 (let [multiply-by-5 (partial * 5)] @@ -17,8 +16,8 @@ "Don't forget: first things first" (= [__ __ __ __] - (let [ab-adder (partial concat [:a :b])] - (ab-adder [__ __]))) + (let [ab-adder (partial concat [:a :b])] + (ab-adder [__ __]))) "Functions can join forces as one 'composed' function" (= 25 (let [inc-and-square (comp square inc)] @@ -30,5 +29,4 @@ "Be careful about the order in which you mix your functions" (= 99 (let [square-and-dec ___] - (square-and-dec 10)))) - + (square-and-dec 10)))) diff --git a/src/koans/datatypes.clj b/src/koans/datatypes.clj index 5e301bae4..9a72d1ac4 100644 --- a/src/koans/datatypes.clj +++ b/src/koans/datatypes.clj @@ -42,4 +42,3 @@ "Surely we can implement our own by now" (= "You're really the Worst Picture, Final Destination 5... sorry." (with-out-str (present (Razzie. "Worst Picture") "Final Destination 5")))) - diff --git a/src/koans/destructuring.clj b/src/koans/destructuring.clj index e23779a64..949b5c53d 100644 --- a/src/koans/destructuring.clj +++ b/src/koans/destructuring.clj @@ -6,19 +6,19 @@ (meditations "Destructuring is an arbiter: it breaks up arguments" (= __ ((fn [[a b]] (str b a)) - [:foo :bar])) + [:foo :bar])) "Whether in function definitions" (= (str "First comes love, " "then comes marriage, " "then comes Clojure with the baby carriage") ((fn [[a b c]] __) - ["love" "marriage" "Clojure"])) + ["love" "marriage" "Clojure"])) "Or in let expressions" (= "Rich Hickey aka The Clojurer aka Go Time aka Macro Killah" (let [[first-name last-name & aliases] - (list "Rich" "Hickey" "The Clojurer" "Go Time" "Macro Killah")] + (list "Rich" "Hickey" "The Clojurer" "Go Time" "Macro Killah")] __)) "You can regain the full argument if you like arguing" @@ -29,14 +29,13 @@ "Break up maps by key" (= "123 Test Lane, Testerville, TX" (let [{street-address :street-address, city :city, state :state} test-address] - __)) + __)) "Or more succinctly" (= "123 Test Lane, Testerville, TX" (let [{:keys [street-address __ __]} test-address] - __)) + __)) "All together now!" (= "Test Testerson, 123 Test Lane, Testerville, TX" - (___ ["Test" "Testerson"] test-address)) -) + (___ ["Test" "Testerson"] test-address))) diff --git a/src/koans/functions.clj b/src/koans/functions.clj index 39ef8cb3d..a0742d107 100644 --- a/src/koans/functions.clj +++ b/src/koans/functions.clj @@ -18,12 +18,12 @@ "One function can beget another" (= __ ((fn [] - ((fn [a b] (__ a b)) - 4 5)))) + ((fn [a b] (__ a b)) + 4 5)))) "Higher-order functions take function arguments" (= 25 (___ - (fn [n] (* n n)))) + (fn [n] (* n n)))) "But they are often better written using the names of functions" (= 25 (___ square))) diff --git a/src/koans/macros.clj b/src/koans/macros.clj index 161f6a231..9c7059d48 100644 --- a/src/koans/macros.clj +++ b/src/koans/macros.clj @@ -11,17 +11,16 @@ (defmacro r-infix [form] (cond (not (seq? form)) - __ + __ (= 1 (count form)) - `(r-infix ~(first form)) + `(r-infix ~(first form)) :else - (let [operator (second form) - first-arg (first form) - others __] - `(~operator - (r-infix ~first-arg) - (r-infix ~others))))) - + (let [operator (second form) + first-arg (first form) + others __] + `(~operator + (r-infix ~first-arg) + (r-infix ~others))))) (meditations "Macros are like functions created at compile time" @@ -41,4 +40,3 @@ "Really, you dont understand recursion until you understand recursion" (= 36 (r-infix (10 + (2 * 3) + (4 * 5))))) - diff --git a/src/koans/maps.clj b/src/koans/maps.clj index a26a6fb50..c0cc7a668 100644 --- a/src/koans/maps.clj +++ b/src/koans/maps.clj @@ -48,4 +48,3 @@ "Or the values" (= (list "Sochi" "Torino" __) (sort (vals {2006 "Torino" 2010 "Vancouver" 2014 "Sochi"})))) - diff --git a/src/koans/recursion.clj b/src/koans/recursion.clj index 043c73bf8..42583056f 100644 --- a/src/koans/recursion.clj +++ b/src/koans/recursion.clj @@ -1,14 +1,14 @@ (defn is-even? [n] (if (= n 0) - __ - (___ (is-even? (dec n))))) + __ + (___ (is-even? (dec n))))) (defn is-even-bigint? [n] (loop [n n acc true] (if (= n 0) - __ - (recur (dec n) (not acc))))) + __ + (recur (dec n) (not acc))))) (defn recursive-reverse [coll] __) diff --git a/src/koans/refs.clj b/src/koans/refs.clj index 0754ff787..0f9b2d2cc 100644 --- a/src/koans/refs.clj +++ b/src/koans/refs.clj @@ -16,14 +16,14 @@ "Alter where you need not replace" (= __ (let [exclamator (fn [x] (str x "!"))] (dosync - (alter the-world exclamator) - (alter the-world exclamator) - (alter the-world exclamator)) + (alter the-world exclamator) + (alter the-world exclamator) + (alter the-world exclamator)) @the-world)) "Don't forget to do your work in a transaction!" (= 0 (do __ - @the-world)) + @the-world)) "Functions passed to alter may depend on the data in the ref" (= 20 (do @@ -31,10 +31,9 @@ "Two worlds are better than one" (= ["Real Jerry" "Bizarro Jerry"] - (do - (dosync - (ref-set the-world {}) - (alter the-world assoc :jerry "Real Jerry") - (alter bizarro-world assoc :jerry "Bizarro Jerry") - __)))) - + (do + (dosync + (ref-set the-world {}) + (alter the-world assoc :jerry "Real Jerry") + (alter bizarro-world assoc :jerry "Bizarro Jerry") + __)))) diff --git a/src/koans/sequence_comprehensions.clj b/src/koans/sequence_comprehensions.clj index 7bcc1c871..b96715519 100644 --- a/src/koans/sequence_comprehensions.clj +++ b/src/koans/sequence_comprehensions.clj @@ -28,5 +28,5 @@ (= [[:top :left] [:top :middle] [:top :right] [:middle :left] [:middle :middle] [:middle :right] [:bottom :left] [:bottom :middle] [:bottom :right]] - (for [row [:top :middle :bottom] column [:left :middle :right]] - __))) + (for [row [:top :middle :bottom] column [:left :middle :right]] + __))) diff --git a/src/koans/sets.clj b/src/koans/sets.clj index e27416b8c..d8c60a497 100644 --- a/src/koans/sets.clj +++ b/src/koans/sets.clj @@ -16,4 +16,3 @@ "But don't forget about the difference" (= __ (clojure.set/difference #{1 2 3 4 5} #{2 3 5}))) -