Last active
October 2, 2016 18:05
-
-
Save YurySolovyov/7fd36108ae365a9defa145b9fa519b7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn count-by-type [items] | |
(vals (frequencies (map :type items)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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