Skip to content

Instantly share code, notes, and snippets.

@0xffea
Created June 19, 2013 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xffea/5813184 to your computer and use it in GitHub Desktop.
Save 0xffea/5813184 to your computer and use it in GitHub Desktop.
Mathics Xor
class Xor(Builtin):
"""
>> Xor[True, False]
= True
>> Xor[True, True]
= False
"""
def apply(self, args, evaluation):
'Xor[args___]'
from sympy.logic.boolalg import Xor
args = [x.to_python() for x in args.get_sequence()]
if Xor(*args):
return Symbol('True')
else:
return Symbol('False')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment