Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes code style #158

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sicp/chapter_1/part_3/ex_1_38.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
(if (= i 1)
1
(if (> (rem (- i 2) 3) 0)
1 ; Each second and third values
(* 2 (+ (/ (- i 2) 3) 1))))) ; 2 * ( ( (i-2)/3) + 1)
1 ; Each second and third values
(* 2 (+ (/ (- i 2) 3) 1))))) ; 2 * ( ( (i-2)/3) + 1)
k))
4 changes: 2 additions & 2 deletions src/sicp/chapter_2/part_2/ex_2_45.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
(fn [painter n]
(if (= n 0)
painter
(let [smaller ((split primary secondary) painter (dec n))
primary-split (primary painter smaller)
(let [smaller ((split primary secondary) painter (dec n))
primary-split (primary painter smaller)
secondary-split (secondary smaller smaller)]
(primary primary-split secondary-split)))))

Expand Down
1 change: 0 additions & 1 deletion src/sicp/chapter_2/part_3/book_2_3.clj
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@
1 1 1 ; C
0)) ; A
(def huffman-message-encoded '(:A :D :A :B :B :C :A))

(def huffman-A '(0))
(def huffman-B '(1 0))
(def huffman-C '(1 1 1))
Expand Down
2 changes: 1 addition & 1 deletion test/sicp/chapter_1/part_2/ex_1_15_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
[sicp.chapter-1.part-2.ex-1-15 :refer [sine]]))

(deftest sine-test
(is (= -0.39980345741334 (sine 12.15)))) ; 5 times, O(log3(n))
(is (= -0.39980345741334 (sine 12.15)))) ; 5 times, O(log3(n))
2 changes: 1 addition & 1 deletion test/sicp/chapter_1/part_2/ex_1_20_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
[sicp.chapter-1.part-2.ex-1-20 :refer [gcd]]))

(deftest gcd-test
(is (= 2 (gcd 206 40)))) ; 4 times
(is (= 2 (gcd 206 40)))) ; 4 times
2 changes: 1 addition & 1 deletion test/sicp/chapter_2/part_2/ex_2_33_test.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns sicp.chapter-2.part-2.ex-2-33-test
(:require
[clojure.test :refer [deftest is]]
[sicp.chapter-2.part-2.ex-2-33 :refer [my-map my-length my-append]]))
[sicp.chapter-2.part-2.ex-2-33 :refer [my-append my-length my-map]]))

(deftest my-map-test
(is (= '(1 2 3) (my-map inc '(0 1 2)))))
Expand Down
12 changes: 6 additions & 6 deletions test/sicp/chapter_2/part_2/ex_2_43_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
[sicp.chapter-2.part-2.ex-2-43 :refer [queens-2-42 queens-2-43]]))

(deftest queens-2-42-test
(is (= 10 (count (queens-2-42 5)))) ; Elapsed time: 6.745917 msecs
(is (= 04 (count (queens-2-42 6)))) ; Elapsed time: 4.257555 msecs
(is (= 40 (count (queens-2-42 7))))) ; Elapsed time: 3.833679 msecs
(is (= 10 (count (queens-2-42 5)))) ; Elapsed time: 6.745917 msecs
(is (= 04 (count (queens-2-42 6)))) ; Elapsed time: 4.257555 msecs
(is (= 40 (count (queens-2-42 7))))) ; Elapsed time: 3.833679 msecs

(deftest queens-2-43-test
(is (= 10 (count (queens-2-43 5)))) ; Elapsed time: 4.883081 msecs
(is (= 04 (count (queens-2-43 6)))) ; Elapsed time: 7.733293 msecs
(is (= 40 (count (queens-2-43 7))))) ; Elapsed time: 6.069276 msecs
(is (= 10 (count (queens-2-43 5)))) ; Elapsed time: 4.883081 msecs
(is (= 04 (count (queens-2-43 6)))) ; Elapsed time: 7.733293 msecs
(is (= 40 (count (queens-2-43 7))))) ; Elapsed time: 6.069276 msecs

; The exercise's method requires O(n^n) recursive calls (instead of O(n))
; exponentially increasing time resource use.
2 changes: 1 addition & 1 deletion test/sicp/chapter_2/part_2/ex_2_49_test.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns sicp.chapter-2.part-2.ex-2-49-test
(:require
[clojure.test :refer [deftest is]]
[sicp.chapter-2.part-2.ex-2-49 :refer [outline-painter x-painter diamond-painter]]))
[sicp.chapter-2.part-2.ex-2-49 :refer [diamond-painter outline-painter x-painter]]))

; I don't know to test it properly...

Expand Down
Loading