From 0913e2edc38b38f2da80d41aa2b28d3861a69947 Mon Sep 17 00:00:00 2001 From: Yves Baumes Date: Sun, 30 Sep 2012 22:32:32 +0200 Subject: [PATCH 1/6] Fix compilation issues. --- ch03-collections-repl-interactions.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ch03-collections-repl-interactions.clj b/ch03-collections-repl-interactions.clj index a666219..4d80d79 100644 --- a/ch03-collections-repl-interactions.clj +++ b/ch03-collections-repl-interactions.clj @@ -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] From 9ec966cc04c46a6799c77301a26d6a3432791109 Mon Sep 17 00:00:00 2001 From: Brian Carper Date: Thu, 29 Aug 2013 01:43:47 -0700 Subject: [PATCH 2/6] Fix typo, missing curly --- ch06-datatypes-repl-interactions.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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])}) ;----- From 957e41ba2b1ffb20c9c2155c886444698a8f3519 Mon Sep 17 00:00:00 2001 From: Brian Carper Date: Thu, 29 Aug 2013 02:04:09 -0700 Subject: [PATCH 3/6] Add missing call to neg? in compare-magnitude --- ch03-collections-repl-interactions.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch03-collections-repl-interactions.clj b/ch03-collections-repl-interactions.clj index 4d80d79..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 From 2d85848f7cd0e02243607e57a03e9e86fc56446f Mon Sep 17 00:00:00 2001 From: Brian Carper Date: Thu, 29 Aug 2013 02:19:54 -0700 Subject: [PATCH 4/6] Typo in defrecord example --- ch12-patterns-repl-interactions.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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!")) From 944331531a63381350f4fb9eb4f865375cb4b8f5 Mon Sep 17 00:00:00 2001 From: Brian Carper Date: Thu, 29 Aug 2013 02:28:18 -0700 Subject: [PATCH 5/6] Change :username to :user, to comply with JDBC --- ch14-rdbms-repl-interactions.clj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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"} From bcc7c58862982a5793e22788fc11a9ed7ffc548f Mon Sep 17 00:00:00 2001 From: Chas Emerick Date: Mon, 9 Sep 2013 06:48:24 -0400 Subject: [PATCH 6/6] fix recursive odd?/even? --- ch01-welcome-repl-interactions.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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