Clojure中的算术重载

Clojure中的算术重载,clojure,arity,Clojure,Arity,为什么以下函数在Clojure中不起作用: (defn tests [] 0 [a b] 1) 它给出以下错误:clojure.lang.Compiler$CompilerException:java.lang.RuntimeException:无法解析符号:a在此上下文中每个符号都需要用括号括起来 (defn tests ([] 0) ([a b] 1)) 如果您想要2倍以上的var,请使用&更多: (defn maxz "Returns the greatest

为什么以下函数在Clojure中不起作用:

(defn tests
  [] 0
  [a b] 1)

它给出以下错误:
clojure.lang.Compiler$CompilerException:java.lang.RuntimeException:无法解析符号:a在此上下文中

每个符号都需要用括号括起来

(defn tests 
  ([] 0) 
  ([a b] 1))

如果您想要2倍以上的var,请使用
&更多:

(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