Difference between revisions of "Control Structures"

From Kolmafia
Jump to navigation Jump to search
imported>Dj d
imported>Dj d
(added repeat/until)
Line 16: Line 16:
  
 
{}
 
{}
 +
== repeat until ==
 +
repeat
 +
{}
 +
until (boolean)
 
== for ==
 
== for ==
 
for x from a to b by c
 
for x from a to b by c

Revision as of 17:47, 3 October 2009

if/else

if (boolean)

{}

else if (boolean)

{}

else

{}

while

while (boolean)

{}

repeat until

repeat {} until (boolean)

for

for x from a to b by c

is the general case. You don't need to specify whether it's going up or down - although doing so by using upto or downto does allow a runtime check to make sure you didn't screw up.

If you don't specify "c", it defaults to incrementing/decrementing by 1. The first iteration is at a and the last is at b (that is to say, it goes from a to b, inclusive).

foreach

foreach x in map

{}

See http://kolmafia.sourceforge.net/advanced.html#maps for details.