@inscribe
+@sec_unary_math
@SimpleFunctionWrapper
def succ(S):
'''Increment TOS.'''
@inscribe
+@sec_unary_math
@SimpleFunctionWrapper
def pred(S):
'''Decrement TOS.'''
S_i = Symbol('i')
S_ifte = Symbol('ifte')
S_infra = Symbol('infra')
+S_pop = Symbol('pop')
S_step = Symbol('step')
S_times = Symbol('times')
S_swaack = Symbol('swaack')
# return stack, expression, dictionary
+def loop_true(stack, expression, dictionary):
+ quote, (flag, stack) = stack # pylint: disable=unused-variable
+ return stack, concat(quote, (S_pop, expression)), dictionary
+
+def loop_two_true(stack, expression, dictionary):
+ quote, (flag, stack) = stack # pylint: disable=unused-variable
+ return stack, concat(quote, (S_pop, concat(quote, (S_pop, expression)))), dictionary
+
+def loop_false(stack, expression, dictionary):
+ quote, (flag, stack) = stack # pylint: disable=unused-variable
+ return stack, expression, dictionary
+
+
@inscribe
-#@combinator_effect(_COMB_NUMS(), b1, s6)
+@poly_combinator_effect(_COMB_NUMS(), [loop_two_true, loop_true, loop_false], b1, s6)
@FunctionWrapper
def loop(stack, expression, dictionary):
'''
ifte=(s7, (s6, (s5, s4))),
nullary=(s7, s6),
run=(s7, s6),
-
)
+EXPECTATIONS['while'] = (s7, (s6, s5))
for name in '''
ifte
run
dupdipd codireco
+ while
'''.split():
C = _dictionary[name]
expect = EXPECTATIONS.get(name)
# -*- coding: utf_8
-from logging import getLogger
+from logging import getLogger, addLevelName
_log = getLogger(__name__)
+addLevelName(15, 'hmm')
from collections import Counter
from itertools import imap, chain, product
def _log_it(e, F):
- _log.debug(
- u'%3i %s ∘ %s',
- len(inspect_stack()),
- doc_from_stack_effect(*F),
- expression_to_string(e),
- )
+ _log.log(
+ 15,
+ u'%3i %s ∘ %s',
+ len(inspect_stack()),
+ doc_from_stack_effect(*F),
+ expression_to_string(e),
+ )
def infer(*expression):