Integrated Dynamics

Integrated Dynamics

63M Downloads

How to implement a logical XOR operator?

zjuwyz opened this issue · 2 comments

commented

Issue type:

  • ❓ Question

Question:

Although we have an xor operator for integers, we don't have one for booleans. It's not hard to create a static version, since a ^ b = (a || b) && (a !&& b).

However, static version isn't good enough for me, since I'd like to use it multiple times. However, when I'm trying to implement an xor operator (with form Boolean->Boolean->Boolean, to be exact) using applie/pipes, etc. It turns out to be extremely difficult. After thinking for a long time I even suspect whether it's really possible under the ID operator system.

Any ideas?

commented

Should be possible to do AFAIK.
Perhaps @GreyMario has done this before?

commented

..Hold up.

The truth table for boolean XOR is

 |01
-+--
0|01
1|10

Now, let's think of another way to describe this. Say... A == !B. Whether A equals the inverse of B.

This will be much easier to implement. Simply pipe a negating function into the first input of a Relational Equals and you have your XOR.