Skip to content

Booleans

HactarCE edited this page May 1, 2020 · 3 revisions

Boolean logic

NDCA does not have a separate boolean type; boolean values are represented using integers with the value 0 for "false" and 1 for "true."

Conversion to boolean

Some types support conversion into a boolean using the function bool(). bool() returns 0 for "falsey" values and 1 for "truthy" values.

An integer is if "falsey" if is 0 and "truthy" otherwise. bool(some_int) is equivalent to some_int != 0.

A cell state is "falsey" if it is state #0 and "truthy" otherwise. bool(some_cell_state) is equivalent to some_cell_state != #0.

A vector is "falsey" if all of its components are 0 and "truthy" if any of its components is nonzero. bool(some_vector) is equivalent to some_vector != 0. (See Vector for info about converting integers to vectors.)

Boolean operations

The following boolean operations are supported (where a and b are types that can be converted to booleans):

  • a and b — logical AND
  • a or b — logical OR ("inclusive or")
  • a xor b — logical XOR ("exclusive or")
  • not a — logical NOT

All of these operations automatically convert their arguments to booleans first.

Clone this wiki locally