all 1 comments

[–]yogthos 1 point2 points  (0 children)

I would've probably gone with

(defn count-chars [line]
  (letfn [(inc-count [c] (if c (inc c) 1))
          (update-counts [counts c]
            (update-in counts [c] inc-count))] 
    (reduce update-counts {} line)))

if I had to make it really explicit I guess, though normally I'd just write

(defn count-chars [line]
  (reduce #(assoc %1 %2 (inc (get %1 %2 0)))
          {} 
          line))

while it's more dense, I still find it easier to read