Brace expansion: Difference between revisions

m
→‎{{header|Raku}}: Fix comment: Perl 6 --> Raku
m (→‎{{header|Haskell}}: Fix link: Perl 6 --> Raku)
m (→‎{{header|Raku}}: Fix comment: Perl 6 --> Raku)
Line 2,405:
=={{header|Raku}}==
(formerly Perl 6)
The task description allows the taking of shortcuts, but please note that we are not taking any shortcuts here. The solution is short because this particular problem happens to map quite naturally to the strengths of Perl 6Raku.
 
First, the parsing is handled with a grammar that can backtrack in the few places this problem needs it. The <tt>+</tt> quantifier matches one or more alternatives (we handle the case of a single alternative in the walk now), and the <tt>%</tt> modifier requires a comma between each quantified item to its left. Note that the <tt>*</tt> quantifiers do <i>not</i> backtrack here, because the <tt>token</tt> keyword suppresses that; all the backtracking here fails over to a different alternative in an outer alternation (that is, things separated by the <tt>|</tt> character in the grammar. Most of these failovers just nibble an uninteresting character and continue.)
2,392

edits