Skip to content

Commit

Permalink
Extend prefix and postfix array hypers to handle nested hashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Jun 4, 2010
1 parent a1695f0 commit 738fad4
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/core/metaops.pm
Expand Up @@ -154,19 +154,10 @@ our multi sub hyper(&op, $lhs, %rhs, :$dwim-left, :$dwim-right) {
our multi sub hyper(&op, @arg) {
my @result;
for @arg {

# this should work, but isn't :(

# if $_ ~~ Iterable {
# @result.push([hyper(&op, $_)]);
# } else {
# @result.push(op($_));
# }

# this is terribly ugly; but works

@result.push([hyper(&op, $_)]) if Iterable.ACCEPTS($_);
@result.push(op($_)) if !Iterable.ACCEPTS($_);
@result.push(hyper(&op, $_)) if Associative.ACCEPTS($_);
@result.push([hyper(&op, $_)]) if !Associative.ACCEPTS($_) && Iterable.ACCEPTS($_);
@result.push(op($_)) if !Associative.ACCEPTS($_) && !Iterable.ACCEPTS($_);
}
@result
}
Expand Down

0 comments on commit 738fad4

Please sign in to comment.