我正在完成本教程:http://moxleystratton.com/clojure/clojure-tutorial-for-the-non-lisp-programmer
并遇到了这个片段:
user=> (loop [i 0]
(when (< i 5)
(println "i:" i)
(recur (inc i))))
i: 0
i: 1
i: 2
i: 3
i: 4
nil
Run Code Online (Sandbox Code Playgroud)
对我的翻译很有用!
? lein repl
nREPL server started on port 50974
REPL-y 0.1.10
Clojure 1.5.1
Run Code Online (Sandbox Code Playgroud)
现在我正在寻找一些关于什么的文档recur
.
它不在这里! http://clojure.github.io/clojure/api-index.html
我花了一段时间才发现它是一个"特殊形式",因此在本页中进行了描述.
那里有一个具有单一连贯索引的汇编吗?
尝试使用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
Run Code Online (Sandbox Code Playgroud)
它适用于函数,宏,特殊形式,变量 - 几乎所有东西.