On 2/28/07, [EMAIL PROTECTED] wrote:
Ranges are not autoreversing: C<2..1> is always a null range.
I assume the reason for not having ranges automatically go in either
direction is that it would make it easier for subtle bugs to creep in
when either end is smaller (or bigger) than you expected, and doing
nothing is usually preferable to doing the wrong thing.
Still, it would be useful to have a way to travel in whatever
direction is the "natural" one... and the whatever term seems an
obvious choice. So can :by(*) for a range mean "go up or down
according to whichever way makes sense"?
To iterate a range in reverse use:
2..1:by(-1)
reverse 1..2
(The C<reverse> is preferred because it works for alphabetic ranges as well.)
:by(*) is not only nicer than :by( ($a>$b) ?? -1 !! +1), but it could
presumably also increment or decrement suitably for the types
involved.
-David