WOLFRAM SYSTEM MODELER

oneTrue

Returns true, if exactly one element of the Boolean input vector is true ("xor")

Wolfram Language

In[1]:=
SystemModel["Modelica.Math.BooleanVectors.oneTrue"]
Out[1]:=

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

oneTrue(b);

Description

Returns true if exactly one element of the input Boolean vector b is true. Otherwise the function returns false. If b is an empty vector, i.e., size(b,1)=0, the function returns false.

Example

  Boolean b1[3] = {false, false, false};
  Boolean b2[3] = {false, true, false};
  Boolean b3[3] = {false, true, true};
  Boolean r1, r2, r3;
algorithm
  r1 = oneTrue(b1);  // r1 = false
  r2 = oneTrue(b2);  // r2 = true
  r3 = oneTrue(b3);  // r3 = false

See also

allTrue, andTrue, anyTrue, countTrue, enumerate, firstTrueIndex, and index.

Syntax

result = oneTrue(b)

Inputs (1)

b

Type: Boolean[:]

Description: Boolean vector

Outputs (1)

result

Type: Boolean

Description: = true, if exactly one element of b is true