Skip to content

Commit f4c4fd5

Browse files
committed
Update Clojure code
1 parent 627af25 commit f4c4fd5

File tree

4 files changed

+39
-12
lines changed
  • compiled_starters/clojure/src/http_server
  • solutions/clojure/01-at4
  • starter_templates/clojure/code/src/http_server

4 files changed

+39
-12
lines changed

compiled_starters/clojure/src/http_server/core.clj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@
77

88
(def port 4221)
99

10+
(alter-var-root #'*out* (constantly *err*))
11+
1012
(defn serve []
1113
(let [server-sock (ServerSocket. port)]
1214
(.setReuseAddress server-sock true)
1315
(.accept server-sock)
14-
(println "accepted new connection")))
16+
(binding [*out* (java.io.PrintWriter. System/out true)]
17+
(println "accepted new connection"))))
1518

1619
(defn -main [& args]
1720
;; You can use print statements as follows for debugging, they'll be visible when running tests.
18-
(binding [*out* *err*]
19-
(println "Logs from your program will appear here!"))
21+
(println "Logs from your program will appear here!")
22+
23+
24+
(alter-var-root #'*out* (constantly (java.io.PrintWriter. System/out true)))
25+
2026

2127
;; Uncomment this block to pass the first stage
2228
;;(serve)
29+
2330
)

solutions/clojure/01-at4/code/src/http_server/core.clj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77

88
(def port 4221)
99

10+
(alter-var-root #'*out* (constantly *err*))
11+
1012
(defn serve []
1113
(let [server-sock (ServerSocket. port)]
1214
(.setReuseAddress server-sock true)
1315
(.accept server-sock)
14-
(println "accepted new connection")))
16+
(binding [*out* (java.io.PrintWriter. System/out true)]
17+
(println "accepted new connection"))))
1518

1619
(defn -main [& args]
17-
(println "Logs from your program will appear here!"))
20+
21+
(alter-var-root #'*out* (constantly (java.io.PrintWriter. System/out true)))
22+
1823

1924
(serve)
25+
2026
)
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@@ -1,23 +1,20 @@
1+
@@ -1,30 +1,26 @@
22
(ns http-server.core
33
(:require
44
[clojure.java.io :as io])
@@ -8,18 +8,25 @@
88

99
(def port 4221)
1010

11+
(alter-var-root #'*out* (constantly *err*))
12+
1113
(defn serve []
1214
(let [server-sock (ServerSocket. port)]
1315
(.setReuseAddress server-sock true)
1416
(.accept server-sock)
15-
(println "accepted new connection")))
17+
(binding [*out* (java.io.PrintWriter. System/out true)]
18+
(println "accepted new connection"))))
1619

1720
(defn -main [& args]
1821
- ;; You can use print statements as follows for debugging, they'll be visible when running tests.
19-
- (binding [*out* *err*]
20-
(println "Logs from your program will appear here!"))
22+
- (println "Logs from your program will appear here!")
23+
-
24+
25+
(alter-var-root #'*out* (constantly (java.io.PrintWriter. System/out true)))
26+
2127

2228
- ;; Uncomment this block to pass the first stage
2329
- ;;(serve)
2430
+ (serve)
31+
2532
)

starter_templates/clojure/code/src/http_server/core.clj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@
77

88
(def port 4221)
99

10+
(alter-var-root #'*out* (constantly *err*))
11+
1012
(defn serve []
1113
(let [server-sock (ServerSocket. port)]
1214
(.setReuseAddress server-sock true)
1315
(.accept server-sock)
14-
(println "accepted new connection")))
16+
(binding [*out* (java.io.PrintWriter. System/out true)]
17+
(println "accepted new connection"))))
1518

1619
(defn -main [& args]
1720
;; You can use print statements as follows for debugging, they'll be visible when running tests.
18-
(binding [*out* *err*]
19-
(println "Logs from your program will appear here!"))
21+
(println "Logs from your program will appear here!")
22+
23+
24+
(alter-var-root #'*out* (constantly (java.io.PrintWriter. System/out true)))
25+
2026

2127
;; Uncomment this block to pass the first stage
2228
;;(serve)
29+
2330
)

0 commit comments

Comments
 (0)