On Thu, Dec 25, 2008 at 1:55 AM, Stephen Weeks <[email protected]> wrote:
> Not long ago, Mark J. Reed proclaimed...
>> What's the consensus on how to do an idiomatic countdown loop? I used
>> for [1..$n].reverse...
>
> This: will work eventually:
> for $n..1:by(-1) { ... }
Cool.
> This currently works in rakudo:
> for (1..$n).reverse { ... }
No, it doesn't (r34384)
for (1..10).reverse { say $^i }
01 9 8 7 6 5 4 3 2 1
The list is flattened into a string and then reversed by character;
the body of the loop is executed only once. That's why I used the
square brackets in my version.
-
Mark J. Reed <[email protected]>