2013-04-09 49 views
2

我通过本教程:http://moxleystratton.com/clojure/clojure-tutorial-for-the-non-lisp-programmer的Clojure:文档

而且遇到了这个片断:

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

对我的翻译的伟大工程!

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

现在我要寻找什么recur是一些文档。

这不是在这里! http://clojure.github.io/clojure/api-index.html

我花了一段时间才弄明白这是一个“特殊形式”,因此在this page中有描述。

有汇编,在那里,有一个单一的连贯的指数?

回答

8

尝试使用内置的文档中的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 

它的工作原理上的功能,宏,特殊形式,变量 - 几乎所有东西。

+3

(使用'clojure.repl)在'user'以外的命名空间中使用它 – 2013-04-09 02:11:22

2

上clojuredocs.org搜索框是一个伟大的起点开始,他们提供的形式和功能非常complete list。要知道,目前Clojure的文档是不是最新的使用Clojure的最新版本,但这样也有一些细微的差别。在实践中,official api page足够完整,最先进的日期。它不具有所有的特殊形式,虽然有Clojure中的极少数特殊形式,所以这是不是经常有问题

+0

我一直在利用clojuredocs.org的为好。但是,例如,在那里的搜索上找不到“for”。我想这两个站点中至少有一个会针对任何特定的form/func/var进入。 – 2013-04-09 01:59:20

+0

clojuredocs搜索有点奇怪。 'for'不会返回for的结果,但如果您在搜索框中键入并等待一秒,则会看到for的条目。或者,您可以直接访问资源,http://clojuredocs.org/clojure_core/clojure.core/for - 根据需要更换条款。 – georgek 2013-04-09 06:26:08