leekscript-next icon indicating copy to clipboard operation
leekscript-next copied to clipboard

[collection] .frequencies() method

Open 5pilow opened this issue 5 years ago • 1 comments

Possible on every collection, constructs a map with elements as keys and number of occurrences as values.

[1, 1, 2, 3, 3].frenquencies() // [1: 2, 2: 1, 3: 2]
"abbacddd".frequencies() // ['a': 2, 'b': 2, 'c': 1, 'd': 3]
<1, 2, 3, 4>.frequencies() // [1: 1, 2: 1, 3: 1, 4: 1]

5pilow avatar Dec 07 '19 20:12 5pilow

histogram could be a good name too

NyalephTheCat avatar May 06 '22 15:05 NyalephTheCat