2
可能重複:
Why clojure's vector function definition is so verbose?爲什麼Clojure的定義與冗餘功能參數條款
爲了澄清我的問題,讓我們的list*
爲例定義。
(defn list*
"Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence."
{:added "1.0"
:static true}
([args] (seq args))
([a args] (cons a args))
([a b args] (cons a (cons b args)))
([a b c args] (cons a (cons b (cons c args))))
([a b c d & more]
(cons a (cons b (cons c (cons d (spread more)))))))
我的問題是,爲什麼不定義list*
這樣的:
(defn list*
"Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence."
{:added "1.0"
:static true}
([args] (seq args))
([a & more] (cons a (spread more))))
檢出:http://stackoverflow.com/questions/11570782/why-clojures-vector-function-definition-is-so-verbose?rq=1 – Ankur 2012-08-10 06:02:46