in reply to Quick way to find the letter with the most occurences in a string
use List::Util 'reduce'; use 5.010; my %hash; $hash{$_}++ for split //, $my_string; say "Most frequent: ", reduce {$hash{$a} > $hash{$b} ? $a : $b} keys % +hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Quick way to find the letter with the most occurences in a string
by choroba (Cardinal) on May 19, 2010 at 16:44 UTC | |
by JavaFan (Canon) on May 19, 2010 at 21:17 UTC | |
by choroba (Cardinal) on May 20, 2010 at 01:10 UTC |