Minor cleanup
This commit is contained in:
parent
94929e8520
commit
6b07d7d30b
|
|
@ -3,8 +3,6 @@ ALIASES = (
|
||||||
('mod', ['%', 'rem', 'remainder', 'modulus']),
|
('mod', ['%', 'rem', 'remainder', 'modulus']),
|
||||||
('getitem', ['pick', 'at']),
|
('getitem', ['pick', 'at']),
|
||||||
('xor', ['^']),
|
('xor', ['^']),
|
||||||
('eh', ['?']),
|
|
||||||
('id', [u'•']),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -130,10 +130,10 @@ x ≡ dup i
|
||||||
pam ≡ [i] map
|
pam ≡ [i] map
|
||||||
|
|
||||||
|
|
||||||
nullary ≡ [stack] dinfrirst
|
nullary ≡ [stack] dip infra first
|
||||||
unary ≡ nullary popd
|
unary ≡ nullary popd
|
||||||
binary ≡ unary popd
|
binary ≡ unary popd
|
||||||
ternary ≡ binary popd
|
ternary ≡ binary popd
|
||||||
|
|
||||||
ccccons ≡ ccons ccons
|
ccccons ≡ ccons ccons
|
||||||
ccons ≡ cons cons
|
ccons ≡ cons cons
|
||||||
|
|
@ -558,7 +558,9 @@ def text_to_expression(text):
|
||||||
'''
|
'''
|
||||||
frame = []
|
frame = []
|
||||||
stack = []
|
stack = []
|
||||||
|
|
||||||
for tok in text.replace('[', ' [ ').replace(']', ' ] ').split():
|
for tok in text.replace('[', ' [ ').replace(']', ' ] ').split():
|
||||||
|
|
||||||
if tok == '[':
|
if tok == '[':
|
||||||
stack.append(frame)
|
stack.append(frame)
|
||||||
frame = []
|
frame = []
|
||||||
|
|
@ -899,7 +901,7 @@ def i(stack, expr, dictionary):
|
||||||
return stack, push_quote(quote, expr), dictionary
|
return stack, push_quote(quote, expr), dictionary
|
||||||
|
|
||||||
|
|
||||||
LOOP = Symbol('loop')
|
S_loop = Symbol('loop')
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
|
|
@ -921,7 +923,7 @@ def loop(stack, expr, dictionary):
|
||||||
isnt_bool(flag)
|
isnt_bool(flag)
|
||||||
isnt_stack(quote)
|
isnt_stack(quote)
|
||||||
if flag:
|
if flag:
|
||||||
expr = push_quote((quote, (LOOP, ())), expr)
|
expr = push_quote((quote, (S_loop, ())), expr)
|
||||||
expr = push_quote(quote, expr)
|
expr = push_quote(quote, expr)
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
@ -1349,6 +1351,21 @@ inscribe(UnaryWrapper(isnt_stack))
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
S_swaack = Symbol('swaack')
|
||||||
|
S_genrec = Symbol('genrec')
|
||||||
|
S_ifte = Symbol('ifte')
|
||||||
|
S_infra = Symbol('infra')
|
||||||
|
S_first = Symbol('first')
|
||||||
|
S_primrec = Symbol('primrec')
|
||||||
|
S_choice = Symbol('choice')
|
||||||
|
S_i = Symbol('i')
|
||||||
|
S_cond = Symbol('cond')
|
||||||
|
S_step = Symbol('step')
|
||||||
|
S_times = Symbol('times')
|
||||||
|
|
||||||
|
_ifte_ = (S_infra, (S_first, (S_choice, (S_i, ()))))
|
||||||
|
|
||||||
|
|
||||||
def dnd(stack, from_index, to_index):
|
def dnd(stack, from_index, to_index):
|
||||||
'''
|
'''
|
||||||
Given a stack and two indices return a rearranged stack.
|
Given a stack and two indices return a rearranged stack.
|
||||||
|
|
@ -1857,9 +1874,6 @@ def dupdip(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_swaack = Symbol('swaack')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def infra(stack, expr, dictionary):
|
def infra(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
@ -1880,10 +1894,6 @@ def infra(stack, expr, dictionary):
|
||||||
return aggregate, expr, dictionary
|
return aggregate, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_genrec = Symbol('genrec')
|
|
||||||
S_ifte = Symbol('ifte')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def genrec(stack, expr, dictionary):
|
def genrec(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
@ -1949,10 +1959,6 @@ def genrec(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_infra = Symbol('infra')
|
|
||||||
S_first = Symbol('first')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def map_(stack, expr, dictionary):
|
def map_(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
@ -1973,9 +1979,6 @@ def map_(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_primrec = Symbol('primrec')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def primrec(stack, expr, dictionary):
|
def primrec(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
@ -2021,21 +2024,10 @@ def primrec(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_choice = Symbol('choice')
|
|
||||||
S_i = Symbol('i')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def ifte(stack, expr, dictionary):
|
def ifte(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
If-Then-Else Combinator
|
If-Then-Else Combinator
|
||||||
::
|
|
||||||
|
|
||||||
... [if] [then] [else] ifte
|
|
||||||
---------------------------------------------------
|
|
||||||
... [[else] [then]] [...] [if] infra select i
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
... [if] [then] [else] ifte
|
... [if] [then] [else] ifte
|
||||||
|
|
@ -2047,15 +2039,11 @@ def ifte(stack, expr, dictionary):
|
||||||
if-part using infra.
|
if-part using infra.
|
||||||
'''
|
'''
|
||||||
else_, then, if_, stack = get_n_items(3, stack)
|
else_, then, if_, stack = get_n_items(3, stack)
|
||||||
e = (S_infra, (S_first, (S_choice, (S_i, ()))))
|
expr = push_quote(_ifte_, expr)
|
||||||
expr = push_quote(e, expr)
|
|
||||||
stack = (if_, (stack, (then, (else_, stack))))
|
stack = (if_, (stack, (then, (else_, stack))))
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_cond = Symbol('cond')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def cond(stack, expr, dictionary):
|
def cond(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
@ -2167,10 +2155,6 @@ def cmp_(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
S_step = Symbol('step')
|
|
||||||
S_times = Symbol('times')
|
|
||||||
|
|
||||||
|
|
||||||
@inscribe
|
@inscribe
|
||||||
def step(stack, expr, dictionary):
|
def step(stack, expr, dictionary):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue