ID:133042
 
Is there any reason why for loops "from A to B" can't be made to count backwards? For example:

for(var/x in 10 to 1)
world << "Countdown: [x]"


That doesn't work at all because for loops like that will only count from a small number to a large number. Its actually rather annoying when you don't know which of the two numbers is going to be larger, and all you want is the range of numbers in between, regardless of which is larger.

Or maybe there is just a better way to do this and I shouldn't be trying to program at 2am...
See [link] interesting undocumented feature.
Something for a weekly digest, I'd say.
*grins at Tiberath*
In response to Schnitzelnagler
Schnitzelnagler wrote:
See [link] interesting undocumented feature.
Something for a weekly digest, I'd say.
*grins at Tiberath*

Crikey, I've never even heard of that one before. That'll be handy.
In response to Schnitzelnagler
Besides this, there is the rather obvious 'raw' form of for:

for(variable = value, conditional, expression)

The other versions, I'd expect, just translate to this. F.ex:

for(var/x = 100, x > 0, x = x - 5) is equivelant to for(var/x = 100 to 0 step -5)

The following is also valid:
for(var/x = 100, x > 0, x = Decrease(x))

proc/Decrease(x)
return x - 1
In response to Alathon
No idea why Alathon made the 'raw' form look as complicated.

Where this is sufficient.
for(var/x = 100, x > 0, x--)
In response to Vermolius
I don't really think Alathon showed it more complicately than you have.

Vermolius wrote:
Where this is sufficient.

Oh, that's too complicated*! :P This is sufficient.
> for(var/x = 100, x--)
>


*: Not really, of course.
In response to Kaioken
Sorry! I suppose I just took a common form to be more useful than throwing that proc in there to stir things up a bit.
In response to Vermolius
Vermolius wrote:
Sorry! I suppose I just took a common form to be more useful than throwing that proc in there to stir things up a bit.

I showed the exact same common form you did above the DM code block; the point was to illustrate that it really does mean expression.