From 373666bf3965de7a2efb1b9f6ebd69d6cb38d7a0 Mon Sep 17 00:00:00 2001 From: sforman Date: Sun, 30 Jul 2023 15:41:58 -0700 Subject: [PATCH] Name Boolean ops. So they don't overshadow the defs for the short-circuiting combinators. --- implementations/Python/joy.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/implementations/Python/joy.py b/implementations/Python/joy.py index 9cfab99..15912de 100644 --- a/implementations/Python/joy.py +++ b/implementations/Python/joy.py @@ -933,7 +933,7 @@ def swap(stack): return (a1, (a2, stack)) -def BinaryLogicWrapper(f): +def BinaryLogicWrapper(f, name=None): ''' Wrap functions that take two numbers and return a single result. ''' @@ -946,6 +946,9 @@ def BinaryLogicWrapper(f): result = f(b, a) return (result, stack), expression, dictionary + if name: + BinaryLogicWrapper_inner.__name__ = name + return BinaryLogicWrapper_inner @@ -1030,9 +1033,9 @@ for F in ( ##╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ UnaryWrapper(bool), # Convert any value to Boolean. # (The only polymorphic function.) - BinaryLogicWrapper(operator.xor), - BinaryLogicWrapper(operator.and_), - BinaryLogicWrapper(operator.or_), + BinaryLogicWrapper(operator.xor, name='_\\/_'), + BinaryLogicWrapper(operator.and_, name='/\\'), + BinaryLogicWrapper(operator.or_, name='\\/'), UnaryLogicWrapper(operator.not_), ##███╗ ███╗ █████╗ ████████╗██╗ ██╗ ##████╗ ████║██╔══██╗╚══██╔══╝██║ ██║ -- 2.11.0