Doing 4clojure for 2 hours, from problem 1 to problem 21 (nth element).
1
Everything is an expression in clojure. So are there any statements?
2
On the command line, `(6 7 8)
is not the same as (6 7 8)
because it is not evaluated. Similiar for :a
versus a
.
3
Searching and parsing the following expressions:
(for [i (range 1 5)] i)
(for [i (range 1 5)](* 2 i))
(do (for [i (range 1 5)](* 2 i)))
(doall (for [i (range 1 5)](* 2 i)))
(print (for [i (range 1 10)](* 2 i)))
4
Reading and deciphering the following answer for nth element:
(def index-of
(fn [a b] ((vec a) b)))
Basically, forcing everything in a vector so that you can use get.