in reply to Re^2: How to write this in Perl 6?
in thread How to write this in Perl 6?
then the following seems to work in the devel version of pugs:multi infix:<XX> (@a, @b) is equiv(&infix:<¥>) { @a.map: -> $a { @b.map: -> $b { ($a, $b) } } }
The first two lines are unchanged. I used gather/take to let me use a for loop and get the inputs in front. The int suppresses the floating notation. The two parameters are passed using placeholder variables, which work as long as they're not nested inside internal braces. (They rely on "base" coming before "offs" in alphabetical order.) And I just used a slice to pull out the four values instead of another map. (Note also that the hyperoperator is still behaving under the old specs of dwimming both sides, but that actually won't work under the latest specs, which requires the quote to be reversed to get dwimmery on that side.) Oh, I also used the unary ^ to get a range from 0 up to the size of the array, which also helped because the XX doesn't quite parse with the correct precedence yet for some reason, so saying 0..^@data would have required extra parens in the current pugs.my @dir = map -> $i { [map {$i*$_}, 0..3] }, 1, 22, 21, 20; my @data = map { .comb, 0 }, @DATA; say max gather { for ^@data XX @dir { take int [*] @data[ $^base »+« $^offs ]; } }
|
|---|