Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

I noticed dedupe and the transducer-returning arity of partition-by use the magic value :clojure.core/none to indicate the start of processing. There are some cases where this results in an incorrect result:

;;;; 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))

Is this a conscious tradeoff for performance or is it something that might use a bit of additional thinking about better handling?

1 Answer

+1 vote
by

So .... don't do that?

by
These should work based on the docstring... Which is why I'm asking.
by
Would a patch be welcome that changes the sigil to `(Object .)` rather than the keyword that is susceptible, albeit not likely, to the confusion here?
by
I guess, low priority thing though.
...