ifelse

ifelse reporter [ commands1 ] [ commands2 ]

Reporter must report a boolean (true or false) value.

If reporter reports true, runs commands1.

If reporter reports false, runs commands2.

The reporter may report a different value for different agents, so some agents may run commands1 while others run commands2.

ask patches
  [ ifelse pxcor > 0
      [ set pcolor blue ]
      [ set pcolor red ] ]
;; the left half of the world turns red and
;; the right half turns blue

See also if, ifelse-value.

Take me to the full NetLogo Dictionary