gpt4 book ai didi

clojure - 为什么 Clojure 在参数子句中定义具有冗余的函数

转载 作者:行者123 更新时间:2023-12-02 05:34:29 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why clojure's vector function definition is so verbose?

为了澄清我的问题,让我们以 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))))

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com