cljs中的cons在哪里定义?
Where is cons defined in cljs?
我无法找到 cons
在 Clojurescript 中的定义位置,因为它不在 ISeq 协议中。
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L616
是编译时的还是运行时的?
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L3297
(defn cons
"Returns a new seq where x is the first element and coll is the rest."
[x coll]
(cond
(nil? coll) (List. nil x nil 1 nil)
(implements? ISeq coll) (Cons. nil x coll nil)
:default (Cons. nil x (seq coll) nil)))
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L3237
(deftype Cons [meta first rest ^:mutable __hash]
ASeq
ISeq
(-first [coll] first)
(-rest [coll] (if (nil? rest) () rest)))
我无法找到 cons
在 Clojurescript 中的定义位置,因为它不在 ISeq 协议中。
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L616
是编译时的还是运行时的?
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L3297
(defn cons
"Returns a new seq where x is the first element and coll is the rest."
[x coll]
(cond
(nil? coll) (List. nil x nil 1 nil)
(implements? ISeq coll) (Cons. nil x coll nil)
:default (Cons. nil x (seq coll) nil)))
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L3237
(deftype Cons [meta first rest ^:mutable __hash]
ASeq
ISeq
(-first [coll] first)
(-rest [coll] (if (nil? rest) () rest)))