MathLib.xor()

MathLib.xor() calculates the exclusive disjunction of the input \[ \text{MathLib.xor}(x_1, \dots, x_n) = \bigoplus_{i=1}^n x_i \]

Specification

MathLib.xor accepts either a list of arguments or one array.
  1. MathLib.xor() = false
  2. MathLib.xor(true) = true
  3. MathLib.xor(false) = false
  4. MathLib.xor$(x_1, \dots, x_n) = \bigoplus_{i=1}^n x_i$

Implementation

MathLib counts the number of truthy values. If this number is odd it returns true and false otherwise.

Tests

Categories: n-ary Function