note
moritz
Not a working solution, just a thought experiment:
<p>Perl 6 has a regex construct spelled <c><*abcd></c>. It is a shortcut for <c>a|ab|abc|abcd</c> (also note that in Perl 6 regexes, the longest pipe-delimited alternative wins, not the first one as in Perl 5).
<p>Sadly no compiler implements the <c><*abcd></c> feature yet, so I can't demonstrate it, but I think something like this should work:
<code>
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>
...
}
</code>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-616540">
[http://perl6.org/|Perl 6 - second systems done right]
</div></div>
903800
903800