Add array tally for ruby

This commit is contained in:
Wilfried OLLIVIER 2023-07-16 15:11:53 +02:00
parent 2b242e2254
commit 75a9e9cf02
1 changed files with 7 additions and 0 deletions

View File

@ -12,3 +12,10 @@ puts true if arr.uniq.length == 1
```ruby
(subarray & array) == array
```
## Compute values occurences
```ruby
[1, 1, 2, 3, 4, 5, 5, 5, 5].tally
=> {1=>2, 2=>1, 3=>1, 4=>1, 5=>4}
```