Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么以下函数在 Clojure 中不起作用:
(defn tests [] 0 [a b] 1)
它给出了以下错误:clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: a in this context
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: a in this context
每个都需要用括号括起来
(defn tests ([] 0) ([a b] 1))
如果您想要超过 2 倍的 var,请使用& more:
& 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)))
(最大 1 2 3 4 5 100 6) => 100
(最大 1 2 3 4 5 100 6)
=> 100