'''
Wrap functions that take two numbers and return a single result.
'''
+
@wraps(f)
def inner(stack, expression, dictionary):
try:
(a, (b, stack)) = stack
except ValueError:
raise StackUnderflowError('Not enough values on stack.')
- if (not isinstance(a, bool)
- or not isinstance(b, bool)
- ):
+ if not isinstance(a, bool) or not isinstance(b, bool):
raise NotABoolError
result = f(b, a)
return (result, stack), expression, dictionary
+
return inner
'''
Wrap functions that take two numbers and return a single result.
'''
+
@wraps(func)
def inner(stack, expression, dictionary):
try:
(a, (b, stack)) = stack
except ValueError:
raise StackUnderflowError('Not enough values on stack.')
- if ( not isinstance(a, int)
+ if (
+ not isinstance(a, int)
or not isinstance(b, int)
- or isinstance(a, bool)
- or isinstance(b, bool)
- ):
+ or isinstance(a, bool)
+ or isinstance(b, bool)
+ ):
raise NotAnIntError
result = func(b, a)
return (result, stack), expression, dictionary
+
return inner
@wraps(f)
def inner(stack, expression, dictionary):
(a, stack) = stack
- if (not isinstance(b, int)
- or isinstance(a, bool)):
+ if not isinstance(b, int) or isinstance(a, bool):
raise NotAnIntError
result = f(a)
return (result, stack), expression, dictionary
tribar = '\u2261' # '≡'
def __init__(self, name, body):
- self.__doc__ = f'{name} {self.tribar} {expression_to_string(body)}'
+ self.__doc__ = (
+ f'{name} {self.tribar} {expression_to_string(body)}'
+ )
self.__name__ = name
self.body = tuple(iter_stack(body))
for line in stream:
if class_.tribar not in line:
continue
- name, body = text_to_expression(line.replace(class_.tribar, ''))
+ name, body = text_to_expression(
+ line.replace(class_.tribar, '')
+ )
if name not in dictionary:
inscribe(class_(name, body), dictionary)