Standardize whitespace a bit more.

This commit is contained in:
Colin Jones 2011-02-13 19:53:25 -06:00
parent a395f47b86
commit ae28d1dd98
2 changed files with 50 additions and 38 deletions

View File

@ -24,21 +24,21 @@
(meditations (meditations
"Macros are like functions created at compile time" "Macros are like functions created at compile time"
(= __ (hello "Macros!")) (= __ (hello "Macros!"))
"Can I haz some infix?" "Can I haz some infix?"
(= __ (infix (9 + 1))) (= __ (infix (9 + 1)))
"Remember, these are nothing but code transformations" "Remember, these are nothing but code transformations"
(= __ (macroexpand '(infix (9 + 1)))) (= __ (macroexpand '(infix (9 + 1))))
"You can do better than that, hand crafting ftw!" "You can do better than that, hand crafting ftw!"
(= __ (macroexpand '(infix-better (10 * 2)))) (= __ (macroexpand '(infix-better (10 * 2))))
"Things dont always work as you would like them to... " "Things dont always work as you would like them to... "
(= __ (macroexpand '(infix-better ( 10 + (2 * 3))))) (= __ (macroexpand '(infix-better ( 10 + (2 * 3)))))
"Really, you dont understand recursion until you understand recursion" "Really, you dont understand recursion until you understand recursion"
(= 36 (r-infix (10 + (2 * 3) + (4 * 5))))) (= 36 (r-infix (10 + (2 * 3) + (4 * 5)))))

View File

@ -11,6 +11,7 @@
false false
6/3 6/3
3]} 3]}
"lists" {"__" [1 2 3 4 5 "lists" {"__" [1 2 3 4 5
1 1
[2 3 4 5] [2 3 4 5]
@ -21,6 +22,7 @@
[:b :c :d :e] [:b :c :d :e]
"No dice!" "No dice!"
()]} ()]}
"vectors" {"__" [1 "vectors" {"__" [1
[] []
[1] [1]
@ -32,11 +34,13 @@
:jelly :jelly
[:butter :and] [:butter :and]
3]} 3]}
"sets" {"__" [3 "sets" {"__" [3
#{1 2 3 4 5} #{1 2 3 4 5}
#{1 2 3 4 5} #{1 2 3 4 5}
#{2 3} #{2 3}
#{1 4}]} #{1 4}]}
"maps" {"__" [0 "maps" {"__" [0
1 1
2 2
@ -52,6 +56,7 @@
1 "January" 1 "January"
2006 2010 2014 2006 2010 2014
"Vancouver"]} "Vancouver"]}
"functions" {"__" [20 "functions" {"__" [20
10 5 10 5
30 2 30 2
@ -59,12 +64,14 @@
20 '*] 20 '*]
"___" ['(fn [f] (f 5)) "___" ['(fn [f] (f 5))
'(fn [f] (f 5))]} '(fn [f] (f 5))]}
"conditionals" {"__" [:a "conditionals" {"__" [:a
[] []
0 0
:glory :glory
4 6 :your_road 4 6 :your_road
''doom 0 ]} ''doom 0 ]}
"higher_order_functions" {"__" [4 8 12 "higher_order_functions" {"__" [4 8 12
'(* x x) '(* x x)
[false false true false false] [false false true false false]
@ -75,18 +82,21 @@
24 24
100 100
'(count a) '(count b)]} '(count a) '(count b)]}
"runtime_polymorphism" {"__" ['(str (:name a) " eats veggies.") "runtime_polymorphism" {"__" ['(str (:name a) " eats veggies.")
'(str (:name a) " eats animals.") '(str (:name a) " eats animals.")
'(str "I don't know what " (:name a) " eats.") '(str "I don't know what " (:name a) " eats.")
"Hello World!" "Hello World!"
"Hello, you silly world." "Hello, you silly world."
"Hello to this group: Peter, Paul, Mary!" ]} "Hello to this group: Peter, Paul, Mary!" ]}
"sequence_comprehensions" {"__" [[0 1 2 3 4 5] "sequence_comprehensions" {"__" [[0 1 2 3 4 5]
'(* index index) '(* index index)
'(range 10) '(range 10)
'(odd? index) '(* index index) '(odd? index) '(* index index)
'[row column] '[row column]
]} ]}
"creating_functions" {"__" [true false true "creating_functions" {"__" [true false true
4 4
:a :b :c :d :a :b :c :d
@ -96,23 +106,25 @@
"___" ['(complement nil?) "___" ['(complement nil?)
'multiply-by-5 'multiply-by-5
'(comp dec square)]} '(comp dec square)]}
"recursion" {"__" [true 'acc "recursion" {"__" [true 'acc
'(loop [n n acc 1] '(loop [n n acc 1]
(if (zero? n) (if (zero? n)
acc acc
(recur (dec n) (* acc n))))] (recur (dec n) (* acc n))))]
"___" ['not]} "___" ['not]}
"destructuring" {"__" [":bar:foo" "destructuring" {"__" [":bar:foo"
'(format (str "First comes %s, " '(format (str "First comes %s, "
"then comes %s, " "then comes %s, "
"then comes %s with the baby carriage") "then comes %s with the baby carriage")
a b c) a b c)
'(apply str '(apply str
(interpose " " (interpose " "
(apply list (apply list
first-name first-name
last-name last-name
(interleave (repeat "aka") aliases)))) (interleave (repeat "aka") aliases))))
'{:original-parts full-name '{:original-parts full-name
:named-parts {:first first-name :last last-name}} :named-parts {:first first-name :last last-name}}
'(str street-address ", " city ", " state) '(str street-address ", " city ", " state)
@ -132,27 +144,27 @@
"___" ['(comp exclamator exclamator exclamator) "___" ['(comp exclamator exclamator exclamator)
'(fn [x] (+ 20 x))]} '(fn [x] (+ 20 x))]}
"macros" {"__" ['~(first form) "macros" {"__" ['~(first form)
'~(nth form 2) '~(nth form 2)
'form 'form
'(drop 2 form) '(drop 2 form)
"Hello, Macros!" "Hello, Macros!"
10 10
''(+ 9 1) ''(+ 9 1)
''(* 10 2) ''(* 10 2)
''(+ 10 (2 * 3))]} ''(+ 10 (2 * 3))]}
"datatypes" {"__" ['(print
(str "You're really the " "datatypes" {"__" ['(print
(.category this) (str "You're really the "
", " recipient "... sorry.")) (.category this)
"peace" ", " recipient "... sorry."))
"literature" "peace"
"physics" "literature"
nil "physics"
[true false] nil
"Congratulations on your Best Picture Oscar, Evil Alien Conquerors!" [true false]
]} (str "Congratulations on your Best Picture Oscar, "
}) "Evil Alien Conquerors!")]}})
(defn replace-with [s k replacements] (defn replace-with [s k replacements]
(let [unreplaced-texts (split s (re-pattern (str "\\b" k "\\b")))] (let [unreplaced-texts (split s (re-pattern (str "\\b" k "\\b")))]