adding arities to frequencies and distinct?

Skip to first unread message

Alex Baranosky

Jun 5, 2015, 12:27:25 PM6/5/15
I've got some utilities that I use occasionally that are built off of distinct and frequencies.

Does anyone think it makes sense to add extra arities to these fns in clojure.core to support this?

(defn frequencies
  "Returns a map from distinct items in coll to the number of times
  they appear."
  {:added "1.2"
   :static true}
     (frequencies identity coll))
  ([keyfn coll]
      (reduce (fn [counts x]
                (let [x' (keyfn x)]
                  (assoc! counts x' (inc (get counts x' 0)))))
              (transient {})

And then a similar change for clojure.core/distinct.

Ghadi Shayban

Jun 5, 2015, 12:56:28 PM6/5/15
I think it would make more sense to add a transducer arity to frequencies.  Distinct not so much, as there is already (into #{}) with a transducer.

Alex Miller

Jun 5, 2015, 2:44:12 PM6/5/15
I'd be happy to have a ticket for frequencies transducer. not for 1.7 at this point...

distinct already has a transducer arity :)  either into as you mention or possibly dedupe are probably better though.

You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages