I'm stuck in a Clojure loop and you need help to get out.
First I want to define a vector
(def lawl [1 2 3 4 5])
I do
(get lawl 0)
And get a "1" in return. Now, I want a loop that gets every number in the vector, so I do:
(loop [i 0] (if (< i (count lawl)) (get lawl i) (recur (inc i))))
In my mind it is assumed that the value of i is nil, then, if I am lower, then the lawl vector counts, it should get each lawl value, and then increase the i-variable from 1 and try again, getting the next value in the vector.
However, this does not work, and I spent some time trying to get it to work and was completely stuck, I would be happy to help. I also tried changing the “if” to “when” with the same result, it does not provide any data, REPL just goes on a new line and blinks.
EDIT: Fixed repetition.
source share