【发布时间】:2013-04-13 00:19:54
【问题描述】:
我正在读一本关于clojure的书,我遇到了一个我不完全理解的例子..
这是repl中的代码:
user=> (repeatedly 10 (rand-int 10))
ClassCastException java.lang.Integer cannot be cast to clojure.lang.IFn clojure.core/repeatedly/fn--4705 (core.clj:4642)
user=> (repeatedly 10 (partial rand-int 10))
(5 0 5 5 2 4 8 8 0 0)
我的问题是:
为什么这里需要partial,以及它如何适合partial 定义,
和repeatedly 定义和语法。部分...
Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
那么这如何适应?
【问题讨论】:
标签: clojure functional-programming jvm read-eval-print-loop