Dave Whipp writes:
> Is it possible to "hyper" a hyper operator?
>
> For example, given:
>
> my @m = ( [1,2], [3,4], [5,6] );
>
> my $a = @m + 1;
> my $b = @m +Â 1;
> my $c = @m +ÂÂ 1;
Those are actually:
my $b = @m Â+Â 1;
my $c = [ map { +$^x } @m ];
Hyper markers go on both sides of any binary operator, even if it's not
hypering both sides. You never see ÂÂ or ÂÂ. See below.
> is it true that:
>
> ok($a == 4);
> ok($b Â==Â [ 3, 3, 3 ];
> ok($c ÂÂ==ÂÂ [ [2,3], [4,5], [6,7] ];
>
> Is there an "infinite depth" hyper operator for operating on trees?
Here's the implementation of hyper operators, from what I know.
sub *infix_circumfix_meta_operator:ÂÂ ($op, $a, $b)
{
given {
when $a ~~ Array && $b ~~ Array {
[ map { _($op, $^x, $^y) } zip($a, $b) ]
}
when $a ~~ Array {
[ map { _($op, $^x, $b) } @$a ]
}
when $b ~~ Array {
[ map { _($op, $a, $^y) } @$b ]
}
default {
$op($a, $b)
}
}
}
So they're always "infinite depth".
Luke