Solving a 4Clojure problem, I got this answer to compress a sequence (problem 30):
#(map first (partition-by identity %))
What would be the best approach to have this work with plain numbers too?
My solution was this:
(defmulti comp class) (defmethod comp java.lang.Long [x] x) (defmethod comp :default [x] (map first (partition-by identity %)))
The code is more than tripled.
Are there better solutions? Shorter? More idiomatic?
I tried extending
ISeqable, but failed miserably.