Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do boolean exclusive or?

Tags:

f#

Apparently there is no boolean version of the bitwise exclusive-or operator (^^^)... what to do?

like image 524
Stephen Swensen Avatar asked Oct 05 '11 02:10

Stephen Swensen


People also ask

Is XOR the same as exclusive or?

XOR is a bitwise operator, and it stands for "exclusive or." It performs logical operation. If input bits are the same, then the output will be false(0) else true(1).


2 Answers

This is provided by the not-equal operator <>.

like image 123
Greg Hewgill Avatar answered Sep 29 '22 17:09

Greg Hewgill


let inline xor a b = (a || b) && not (a && b) 
like image 27
Daniel Avatar answered Sep 29 '22 16:09

Daniel