Execute instructions depending on a condition

if condition [instructions_true]
(if condition [instructions_true] [instructions_false])
ifelse condition [instructions_true] [instructions_false]

Execute list of instructions_true if the condition is true. If the condition is false then go to the next instruction after if or execute instructions_false list it it is provided.

Example:

repeat 4 [
  ifelse repcount % 2 = 0 [print "even] [print "odd]
]

Output:

odd
even
odd
even

See also:

Word, number, boolean value

Table of Content