我注意到 dedupe
和返回 transducer 的 partition-by
使用魔法值 :clojure.core/none
来表示处理开始。在一些情况下,这可能导致结果不正确。
;;;; dedupe
(dedupe
[:clojure.core/none 1 2 3])
;;=> (1 2 3)
;; expected: (:clojure.core/none 1 2 3)
(dedupe
[:clojure.core/none :clojure.core/none 1 2 3])
;;=> (1 2 3)
;; expected: (:clojure.core/none 1 2 3)
;; transducing arity is also affected
(sequence
(dedupe)
[:clojure.core/none 1 2 3])
;;=> (1 2 3)
;; expected: (:clojure.core/none 1 2 3)
;;;; partition-by
(sequence (partition-by
{0 0
1 :clojure.core/none
2 2})
(range 3))
;;=> ([0] [1 2])
;; expected: ([0] [1] [2])
;; non-trasducing arity works OK:
(partition-by
{0 0
1 :clojure.core/none
2 2}
(range 3))
;;=> ((0) (1) (2))
这是否是性能上的一个深思熟虑的权衡,还是可能需要一些额外的思考来更好地处理这个问题呢?