Austin Hastings writes: > > Those are actually: > > > > my $b = @m Â+Â 1; > > my $c = [ map { +$^x } @m ]; > > Boggle! Why wouldn't that be: > > my $c = [ map { $^x Â+Â 1 } @m ]; > > for the last one?
Whoops. I thought I was preserving his original semantic, but I wasn't. I had somehow forgotten for that short moment that he wrote two ÂÂs. The correct line 3 is: my $c = @m Â+Â 1; Just like line 2 :-) > > 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". > > You'll have to explain this. > > 1- What's the _() for? Don't you mean map { $op(...) } in most of > those cases? Remember that &_ is always aliased to the current sub. The reason I don't call $op directly is to get the implicit recursive behavior. Otherwise we'd just get a single-dimensional hyper. > 2- Why does using map {...} @$a make it "infinite depth"? Wouldn't you > have to use [EMAIL PROTECTED] for that, to force flattening? No, map takes a code block as its first argument and a slurpy list as the rest. All I have to do is make $a look like a list. I can do that with either @$a or *$a (they're exactly the same in this context). I preferred the conservative for once. > 3- Assuming that ÂÂ really is 'always infinite depth', how do I make > it not-always-infinite-depth? Use map? To be honest, I'd really feel more comfortable if it were always single dimensional -- I know precisely what's going on. That is, I'd prefer if the hyper syntax were a shortcut for a map, plain and simple. But I suppose it doesn't really matter either way, and making it arbitrary depth is a bit more useful. Just, um: my $a = [ 0 ]; my $b = [ $a ]; $a[0] = $b; $a Â+Â 1; Will produce a mysterious infinite loop. Luke