Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure: documentation

Tags:

clojure

I am working through this tutorial: http://moxleystratton.com/clojure/clojure-tutorial-for-the-non-lisp-programmer

And came across this snippet:

user=> (loop [i 0]
  (when (< i 5)
    (println "i:" i)
    (recur (inc i))))
i: 0
i: 1
i: 2
i: 3
i: 4
nil

Works great on my interpreter!

❯ lein repl
nREPL server started on port 50974
REPL-y 0.1.10
Clojure 1.5.1

Now I am looking for some documentation on what recur is.

It's not in here! http://clojure.github.io/clojure/api-index.html

It took me a while to figure out it's a "Special Form" and thus described in this page.

Is there a compilation out there that has a single coherent index?

like image 575
Steven Lu Avatar asked Jun 06 '26 09:06

Steven Lu


1 Answers

Try using the built in documentation in the REPL:

user=> (doc recur)
-------------------------
recur
  (recur exprs*)
Special Form
  Evaluates the exprs in order, then, in parallel, rebinds
  the bindings of the recursion point to the values of the exprs.
  Execution then jumps back to the recursion point, a loop or fn method.

  Please see http://clojure.org/special_forms#recur

It works on functions, macros, special forms, variables—almost everything.

like image 180
Scott Olson Avatar answered Jun 07 '26 21:06

Scott Olson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!