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