Skip to content

Commit

Permalink
Undo typed hash support for List.(classify|categorize)
Browse files Browse the repository at this point in the history
pmichaud didn't like it.  And he was right.  :-)
  • Loading branch information
lizmat committed Jun 15, 2013
1 parent 693af19 commit 686cf53
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -318,25 +318,25 @@ my class List does Positional {
$tpos >= +$tseq;
}

method classify( &test, :$keytype = Str, :$of = Any ) {
method classify(&test) {
fail 'Cannot .classify an infinite list' if self.infinite; # MMD?
my $result = Hash.new( :$of, :$keytype );
my %result;
for @.list {
$result{test $_}.push: $_;
%result{test $_}.push: $_;
}
$result.pairs;
%result;
}

method categorize( &test, :$keytype = Str, :$of = Any ) {
method categorize(&test) {
fail 'Cannot .categorize an infinite list' if self.infinite; #MMD?
my $result = Hash.new( :$of, :$keytype );
my %result;
for @.list {
my @k = test $_;
for @k -> $k {
$result{$k}.push: $_;
%result{$k}.push: $_;
}
}
$result.pairs;
%result.pairs;
}

# This needs a way of taking a user-defined comparison
Expand Down

0 comments on commit 686cf53

Please sign in to comment.