Skip to content

Commit

Permalink
reimplemented Ƭ as ÐĿ variant
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisMitchell committed May 29, 2018
1 parent 596a3e5 commit 0646e0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions jelly/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,15 @@ def leading_nilad(chain):
def lcm(x, y):
return x * y // (math.gcd(x, y) or 1)

def loop_until_loop(link, args, return_all = False, return_loop = False):
def loop_until_loop(link, args, return_all = False, return_loop = False, vary_rarg = True):
ret, rarg = args
cumret = []
while True:
cumret.append(ret)
larg = ret
ret = variadic_link(link, (larg, rarg))
rarg = larg
if vary_rarg:
rarg = larg
if ret in cumret:
if return_all:
return cumret
Expand Down Expand Up @@ -2916,6 +2917,13 @@ def zip_ragged(array):
call = lambda z = None: copy_to(atoms['®'], variadic_link(links[0], (niladic_link(atoms['®']), z)))
)]
),
'Ƭ': attrdict(
condition = lambda links: links,
quicklink = lambda links, outmost_links, index: [attrdict(
arity = links[0].arity,
call = lambda x = None, y = None: loop_until_loop(links[0], (x, y), return_all = True, vary_rarg = False)
)]
),
'ƭ': attrdict(
condition = lambda links: links and (
(links[-1].arity == 0 and len(links) - 1 == links[-1].call()) or
Expand Down Expand Up @@ -3088,7 +3096,6 @@ def zip_ragged(array):

quicks['Ƈ'] = quicks['Ðf']
hypers['Ɱ'] = hypers['Ѐ']
quicks['Ƭ'] = quicks['ÐĿ']
atoms ['Ẓ'] = atoms ['ÆP']

chain_separators = {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'jellylanguage',
version = '0.1.25',
version = '0.1.26',
packages = [
'jelly'
],
Expand Down

0 comments on commit 0646e0b

Please sign in to comment.