Skip to content

Commit 96d6543

Browse files
committed
Tweak some wording / formatting
1 parent 943ce55 commit 96d6543

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

src/koan_engine/random.clj

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[clojure.string :as s]))
66

77
(def success-quotes
8-
["Hack and be marry!"
8+
["Hack and be merry!"
99
"You're bound to be unhappy if you optimize everything. -Donald Knuth"
1010
"Lisp isn't a language, it's a building material. -Alan Kay"
1111
"The key to performance is elegance. -Jon Bentley and Doug McIlroy"
@@ -14,27 +14,29 @@
1414
(def failure-quotes
1515
["If at first you don't succeed; call it version 0.1"
1616
"I would love to change the world, but they won't give me the source code."
17-
"Loosing is fun. -Dwarf Fortress"
17+
"Losing is fun. -Dwarf Fortress"
1818
"Deleted code is debugged code. -Jeff Sickel"])
1919

2020
(defn- solve-koan [koan]
21-
(print "and the solution is (';' as delimiter): ")
21+
(println)
22+
(print "Your solution (using \";\" as a delimiter): ")
2223
(flush)
2324
(let [solutions (s/split (read-line) #";")
2425
filled-koan (reduce (fn [k s] (s/replace-first k #"\b___?\b" s)) koan solutions)]
2526
(println)
26-
(println "Your solution:\n" filled-koan)
27+
(println "The koan, filled in with your solution:\n" filled-koan)
2728
(if
28-
(or (try
29-
(load-string filled-koan)
30-
(catch AssertionError e (prn e) false)
31-
(catch Exception e (prn e) false))
32-
(= (symbol "skip-koan") (first solutions))
33-
(= "skip-koan" (first solutions))
34-
(= :skip-koan (first solutions)))
35-
(println "Success. " (-> success-quotes shuffle first) "\nNext koan is coming up.\n")
29+
(or (try
30+
(load-string filled-koan)
31+
(catch AssertionError e (prn e) false)
32+
(catch Exception e (prn e) false))
33+
(= (symbol "skip-koan") (first solutions))
34+
(= "skip-koan" (first solutions))
35+
(= :skip-koan (first solutions)))
36+
(println "Success! " (-> success-quotes shuffle first)
37+
"\nNext koan coming right up.\n")
3638
(do
37-
(println "Failed." (-> failure-quotes shuffle first) "\nTry again!")
39+
(println "Oh no, failed!" (-> failure-quotes shuffle first) "\nTry again!")
3840
(solve-koan koan)))))
3941

4042
(defmacro random-koan [prefix-forms & forms]
@@ -43,35 +45,38 @@
4345
shuffle
4446
first)]
4547
((fn [[doc# code#]]
46-
(println "Solve the following koan:")
47-
(println "meditate: " doc#)
48+
(println "-----\nSolve the following koan:")
49+
(println doc#)
4850
(println code#)
4951
(solve-koan (str prefix-forms code#)))
5052
koan)))
5153

5254
(defn- do-run [opts]
5355
(let [{:keys [dojo-resource koan-resource koan-root]} opts
5456
koan-file (-> koan-resource
55-
ordered-koans
56-
shuffle
57-
first)
57+
ordered-koans
58+
shuffle
59+
first)
5860
form (s/replace (slurp (file koan-root (str koan-file ".clj")))
59-
#"\(ns" "(comment")
61+
#"\(ns" "(comment")
6062
form-wo-meditations (-> form
6163
(s/replace #"\(meditations[\s\S]*" "")
6264
(s/replace "\"" "\\\""))]
63-
(println "\nmeditating uppon: " koan-file)
64-
(println "the contex of the koan:\n" form-wo-meditations)
65+
(println "\nMeditating upon: " koan-file)
66+
(println "The contex of the koan:\n"
67+
(s/trim form-wo-meditations)
68+
"\n")
6569
(u/with-dojo [dojo-resource]
66-
(-> (s/replace form "(meditations" (format "(random-koan \"%s\"" form-wo-meditations))
70+
(-> (s/replace form "(meditations" (format "(random-koan \"%s\""
71+
form-wo-meditations))
6772
load-string)))
6873
(do-run opts))
6974

7075
(defn runner [opts]
7176
(println
72-
"Showing a random koan from the project.
73-
You might never reach enlightement but you can play endlessly until you get bored and start writing your own koans!")
77+
"You might never reach enlightement, but you can play endlessly until you get bored and start writing your own koans!")
7478
(println)
7579
(println
76-
"Provide your answer or \"skip-koan\" if you want to skip the current one. You will automatically get the next random koan on success. Use ';' as delimiter if you need to provide multiple answers. If you need to provide multiple answers but only some of those have effect on the given koan you have to provide your solution in the right place; however, what you type for the rest is not important, you can keep them blank or use :skip.")
80+
"Provide your answer or \"skip-koan\" if you want to skip the current one. You will automatically get the next random koan on success. Use \";\" as delimiter if you need to provide multiple answers. If you need to provide multiple answers but only some of those have effect on the given koan you have to provide your solution in the right place; however, what you type for the rest is not important, you can keep them blank or use :skip.")
81+
(println "-----")
7782
(do-run opts))

0 commit comments

Comments
 (0)