为什么以下函数在Clojure中不起作用:
(defn tests
[] 0
[a b] 1)它会给出以下错误:clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: a in this context
发布于 2013-07-05 03:07:24
每一个都需要用括号括起来。
(defn tests
([] 0)
([a b] 1))发布于 2019-12-28 19:08:08
如果需要2倍以上的var,请使用& more:
(defn maxz
"Returns the greatest of the nums."
([x] x)
([x y] (if (> x y) x y))
([x y & more]
(reduce maxz (maxz x y) more)))(maxz 1 2 3 4 5 100 6)
=> 100
https://stackoverflow.com/questions/17476633
复制相似问题