10. lein repl
starts Clojure REPL
$ lein repl
nREPL server started on port 49482 on host 127.0.0.1 - nrepl://1
27.0.0.1:49482
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_121-b13
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=>
20. clojure.repl/doc
prints documentation
clj-demo.core=> (doc map)
-------------------------
clojure.core/map
([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])
Returns a lazy sequence consisting of the result of applying f to
the set of first items of each coll, followed by applying f to the
set of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments. Returns a transducer when
no collection is provided.
nil
21. clojure.repl/source
prints source code
clj-demo.core=> (source map)
(defn map
"Returns a lazy sequence consisting of the result of applying f to
the set of first items of each coll, followed by applying f to the
set of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments. Returns a transducer when
no collection is provided."
{:added "1.0"
:static true}
([f]
(fn [rf]
(fn
([] (rf))
([result] (rf result))
([result input]
(rf result (f input)))
([result input & inputs]
(rf result (apply f input inputs))))))
65. Run koans
$ cd clojure-koans/
$ lein koan run
Starting auto-runner...
Considering /Users/k.ohashi/code/clojure-koans/src/koans/01_equa
lities.clj...
Now meditate upon /Users/k.ohashi/code/clojure-koans/src/koans/0
1_equalities.clj
---------------------
Assertion failed!
clojure.lang.ExceptionInfo: We shall contemplate truth by testin
g reality, via equality
(= __ true) {:line 6}, compiling:(/Users/k.ohashi/code/clojure-k
oans/src/koans/01_equalities.clj:4:1)
77. Save changes and check the meditation result
...
Now meditate upon /Users/k.ohashi/code/clojure-koans/src/koans/0
1_equalities.clj
---------------------
Assertion failed!
clojure.lang.ExceptionInfo: You can test equality of many things
(= (+ 3 4) 7 (+ 2 __)) {:line 12}, compiling:(/Users/k.ohashi/co
de/clojure-koans/src/koans/01_equalities.clj:4:1)