Boolean Operations¶
Since conditions are just booleans, you can perform some simple operations on conditions:
And¶
Outputs true
if and only if the two inputs are both true
.
Start~#1
And(false, false)~#2
Print(#1, #2)~#3
And(false, true)~#4
Print(#3, #4)~#5
And(true, false)~#6
Print(#5, #6)~#7
And(true, true)~#8
Print(#7, #8)
$ decision and.dc
false
false
false
true
Or¶
Outputs true
if and only if either of the two inputs are true
.
Start~#1
Or(false, false)~#2
Print(#1, #2)~#3
Or(false, true)~#4
Print(#3, #4)~#5
Or(true, false)~#6
Print(#5, #6)~#7
Or(true, true)~#8
Print(#7, #8)
$ decision or.dc
false
true
true
true
Not¶
Outputs true
if the input is false
, and outputs false
if the input
is true
.
Start~#1
Not(false)~#2
Print(#1, #2)~#3
Not(true)~#4
Print(#3, #4)
$ decision not.dc
true
false
Xor¶
Outputs true
if and only if only one if the inputs is true
.
Start~#1
Xor(false, false)~#2
Print(#1, #2)~#3
Xor(false, true)~#4
Print(#3, #4)~#5
Xor(true, false)~#6
Print(#5, #6)~#7
Xor(true, true)~#8
Print(#7, #8)
$ decision xor.dc
false
true
true
false