Created
September 22, 2018 10:03
-
-
Save trilliwon/4576196690e772dfce3b46d3e71a2eae to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension Array where Element: Hashable { | |
func counter() -> [Element: Int] { | |
return self.reduce(into: [:]) { counts, elem in counts[elem, default: 0] += 1 } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment