Created
August 1, 2015 14:36
-
-
Save yanick/77f676b8dd8b319ead4d 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
use strict; | |
use warnings; | |
sub hashgregate(&@){ | |
my $sub = shift; | |
my %agg; | |
push @{$agg{$sub->($_)}}, $_ for @_; | |
return wantarray ? %agg : \%agg; | |
} | |
my $first_divisors = hashgregate { my $i = 2; $i++ while $_ % $i; $i } 2..100; | |
use Data::Printer; | |
p $first_divisors; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Hashregate"?! You are a bad person.