Not sure why that doesn't work. But there's always:
say reduce { $^a + $^b }, 1,3,5 # 9
I'm guessing you knew that but it's all I've got for tonight. :)
I've now moved my comment here and expanded it a bit before I go to sleep.
The TTIAR error means it fails to parse the reduce as a reduce. So I decided to take a quick gander at the Perl 6 grammar.
I searched for "reduce" and quickly deduced that it must be failing to match this regex.
While that regex might be only 20 or so lines long, and I recognize most of the constructs, it's clearly not trivial. I imagine there's a way to use Grammar::Debugger
and/or some other grammar debugging tool with the Perl 6 grammar but I don't know it. In the meantime, you must be a bit of a regex whiz by now, so you tell me: why doesn't it match? :)
Update
With Brad's answer to your question as our guide, the answer to my question is instantly obvious. The first line of the regex proper (after the two variable declarations) directly corresponds to the "no spaces" rule that Brad revealed:
<?before '['\S+']'>
This is an assertion that the regex engine is positioned immediately before a string that's of the form [...]
where the ...
is one or more non-space characters. (\s
means space, \S
means non-space.)
(Of course, I'd have been utterly baffled why this non-space rule was there without Brad's answer.)