Skip to content

Instantly share code, notes, and snippets.

@YurySolovyov
Last active October 2, 2016 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YurySolovyov/7fd36108ae365a9defa145b9fa519b7f to your computer and use it in GitHub Desktop.
Save YurySolovyov/7fd36108ae365a9defa145b9fa519b7f to your computer and use it in GitHub Desktop.
(defn count-by-type [items]
(vals (frequencies (map :type items))))
(defn count-by-type [items]
(reduce (fn [[files-count directories-count] item]
(case (:type item)
:file [(inc files-count) directories-count]
:dir [files-count (inc directories-count)]
[files-count directories-count]))
[0 0] items))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment