> I don't understand how loop works.
> (defn lo [x]
> (loop [y 0 x 1]
> (pr y)))
> user=> #'user/lo
> user=> (lo 5)
> what exactly does loop var var var var mean?
'loop' is a binding form like 'let' that also serves as one of the
"jump to" locations for 'recur'. Your example bound y to 0 and x to 1
and then printed y.
> how would I do:
> loop var from 1 to 20, increment by 2
> print var
Here are a few of ways to accomplish the loop you gave:
(defn loop1 
(loop [i 1]
(when (< i 20)
(recur (+ 2 i)))))
(defn loop2 
(dorun (for [i (range 1 20 2)]
(defn loop3 
(doseq i (range 1 20 2)
> Sdenote: the API-reference is great but it would be even better if
> there were examples. One example says more than a thousand words.
> Is there a way to contribute to that?
It's possible to contribute to that on the wiki:
Feel free to add a new section with API examples or look around for a
place they might already fit in. I'm sure any contributions to the
wiki will be much appreciated.