Here's a version that works under pugs:
(Needless to say,) whoa! That's great. Generally I avoid replying for TY-only posts and prefer to /msg instead. But I feel like doing so publicly for this time since it's so nice to actually test the thing myself. I tried a first time and pugs seemed not to like the method call on the HERE doc string. In fact I had 6.2.12 installed; I upgraded to 6.2.13 and it still complains about something:
*** Cannot parse regex: \n *** Error: Error: Can't call method "__RUN__" on an undefined value.
But it does spit out a value.
I would generally prefer to write max as [max], but that's not implemented yet. Also it prints the result in E notation, albeit with sufficient precision.
Indeed, especially since the original problem expected an exact answer in terms of an integer. (The value spitted out doesn't seem to match the Perl 5 version one, but that's definitely a side note in this context. I don't know whether that could be related to the messages above.)
I think there are probably ways to use hyperops to replace some of the maps, but I need to think about it some more. There are also some unimplemented cross operators that might replace nested maps.
That's great as well. The maps look very natural to me, but I'd be delighted to see what hyperops could do instead of them. And I'm particularly excited about the potential cross operators which I also find quite natural, in fact it's one of the first things I asked in p6l: I can do without them, but I miss them more than, say, the somewhat "dual" zip operator. Of course the advantage becomes more evident with more nesting levels than just two...
In reply to Re^2: How to write this in Perl 6?
by blazar
in thread How to write this in Perl 6?
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |