diff --git a/ch01-welcome-repl-interactions.clj b/ch01-welcome-repl-interactions.clj index 9e3ed8d..c5477b5 100644 --- a/ch01-welcome-repl-interactions.clj +++ b/ch01-welcome-repl-interactions.clj @@ -1,4 +1,3 @@ - ;----- (defn average [numbers] @@ -542,10 +541,12 @@ p ;----- (letfn [(odd? [n] - (even? (dec n))) + (if (zero? n) + false + (even? (dec n)))) (even? [n] (or (zero? n) - (odd? (dec n))))] + (odd? (dec n))))] (odd? 11)) ;= true diff --git a/ch03-collections-repl-interactions.clj b/ch03-collections-repl-interactions.clj index a666219..810f7e8 100644 --- a/ch03-collections-repl-interactions.clj +++ b/ch03-collections-repl-interactions.clj @@ -575,7 +575,7 @@ sm ;----- (defn compare-magnitude [a b] - (- (magnitude a) (magnitude b))) + (neg? (- (magnitude a) (magnitude b)))) ((comparator compare-magnitude) 10 10000) ;= -1 @@ -1456,7 +1456,7 @@ b unvisited (disj (set (keys paths)) start-loc)] (if-let [loc (when-let [s (seq unvisited)] (rand-nth s))] (let [walk (iterate (comp rand-nth paths) loc) - steps (zipmap (take-while unvisited walk) (next walk))]<8> + steps (zipmap (take-while unvisited walk) (next walk))] (recur (reduce disj walls (map set steps)) (reduce disj unvisited (keys steps)))) walls)))) @@ -1518,7 +1518,7 @@ b deltas [[2 0] [1 1] [-1 1]]] (set (for [v vertices d deltas f [+ -] :let [w (vertices (map f v d))] - :when w] #{v w})) + :when w] #{v w})))) (defn- hex-outer-walls [w h] @@ -1527,7 +1527,7 @@ b deltas [[2 0] [1 1] [-1 1]]] (set (for [v vertices d deltas f [+ -] :let [w (map f v d)] - :when (not (vertices w))] #{v (vec w)})) + :when (not (vertices w))] #{v (vec w)})))) (defn hex-draw [w h maze] diff --git a/ch06-datatypes-repl-interactions.clj b/ch06-datatypes-repl-interactions.clj index 2b55d9a..1d327ed 100644 --- a/ch06-datatypes-repl-interactions.clj +++ b/ch06-datatypes-repl-interactions.clj @@ -551,7 +551,7 @@ Point [[(:x pt)] [(:y pt)]]) :cols (fn [pt] [[(:x pt) (:y pt)]]) - :dims (fn [pt] [2 1])) + :dims (fn [pt] [2 1])}) ;----- diff --git a/ch12-patterns-repl-interactions.clj b/ch12-patterns-repl-interactions.clj index 3c19387..41ef5fb 100644 --- a/ch12-patterns-repl-interactions.clj +++ b/ch12-patterns-repl-interactions.clj @@ -80,7 +80,7 @@ class MyApp { (defprotocol Bark (bark [this])) -(defrecord Chihuahua [weight price] +(defrecord Chihuahua [] Bark (bark [this] "Yip!")) diff --git a/ch14-rdbms-repl-interactions.clj b/ch14-rdbms-repl-interactions.clj index 97f03ae..0e6cb61 100644 --- a/ch14-rdbms-repl-interactions.clj +++ b/ch14-rdbms-repl-interactions.clj @@ -1,4 +1,3 @@ - ;----- (require '[clojure.java.jdbc :as jdbc]) ;= nil @@ -12,13 +11,13 @@ {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//localhost:3306/databasename" - :username "login" + :user "login" :password "password"} ;----- {:datasource datasource-instance - :username "login" + :user "login" :password "password"}