Reformatting for consistency

master
Aaron Bedra 13 years ago
parent dd232703af
commit 3cca560b96

@ -27,5 +27,4 @@
"When your expectations are aligned with reality things, proceed that way"
(= :fin (do
(compare-and-set! __ __ __)
@atomic-clock))
)
@atomic-clock)))

@ -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)))

@ -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))))

@ -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"))))

@ -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)))

@ -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)))

@ -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)))))

@ -48,4 +48,3 @@
"Or the values"
(= (list "Sochi" "Torino" __)
(sort (vals {2006 "Torino" 2010 "Vancouver" 2014 "Sochi"}))))

@ -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]
__)

@ -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")
__))))

@ -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]]
__)))

@ -16,4 +16,3 @@
"But don't forget about the difference"
(= __ (clojure.set/difference #{1 2 3 4 5} #{2 3 5})))

Loading…
Cancel
Save