in reply to Find Length Of Longest Ascending/Descending Sequence
Perl 6 has a regex construct spelled <*abcd>. It is a shortcut for a|ab|abc|abcd (also note that in Perl 6 regexes, the longest pipe-delimited alternative wins, not the first one as in Perl 5).
Sadly no compiler implements the <*abcd> feature yet, so I can't demonstrate it, but I think something like this should work:
my token longest_asc_desc { # ascending | <*0123456789> ** <?after 9> | <*1234567890> ** <?after 0> | <*2345678901> ** <?after 1> ... # descending: | <*9876543210> ** <?after 0> | <*8765432109> ** <?after 9> | <*7654321098> ** <?after 8> ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find Length Of Longest Ascending/Descending Sequence
by Ratazong (Monsignor) on May 10, 2011 at 09:22 UTC | |
by moritz (Cardinal) on May 10, 2011 at 09:50 UTC |