Follow

user=> (->> "aaaabbbcca" (partition-by identity) (map #(vector (first %) (count %))))
([\a 4] [\b 3] [\c 2] [\a 1])

twitter.com/Al_Grigor/status/1

@nihilipster Your result is not exactly what is asked for: you return a sequence of vectors where the wanted output is a vector of sequences.
(->> (partition-by identity "aaabbbca")
(mapv #(list (first %) (count %)))))
[("a" 3) ("b" 3) ("c" 1) ("a" 1)]

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.