mirror of
https://github.com/Lyxal/Keta.git
synced 2024-08-14 23:53:13 +00:00
Update chainify.py
This commit is contained in:
parent
c90ee6ca82
commit
15a2665023
1 changed files with 9 additions and 7 deletions
10
chainify.py
10
chainify.py
|
@ -1,4 +1,4 @@
|
||||||
dyads = "*+-/%"
|
dyads = "*+-/%@"
|
||||||
monads = list(map(chr, range(ord("A"), ord("Z") + 1)))
|
monads = list(map(chr, range(ord("A"), ord("Z") + 1)))
|
||||||
nilads = "1234567890"
|
nilads = "1234567890"
|
||||||
|
|
||||||
|
@ -16,10 +16,12 @@ for char in source:
|
||||||
|
|
||||||
exprs = []
|
exprs = []
|
||||||
expr = []
|
expr = []
|
||||||
patterns = ["02", "10", "11", "12", "20", "21", "22"]
|
patterns = ["020", "021", "022", "02", "10", "11", "12", "20", "21", "22",
|
||||||
|
"102", "110", "111", "112", "120", "121", "122",
|
||||||
|
"202", "210", "211", "212", "220", "221", "222"]
|
||||||
pattern = ""
|
pattern = ""
|
||||||
while len(arities):
|
while len(arities):
|
||||||
if pattern in patterns:
|
if pattern in patterns and pattern + str(arities[-1][0]) not in patterns:
|
||||||
exprs += [pattern, expr]
|
exprs += [pattern, expr]
|
||||||
expr = []
|
expr = []
|
||||||
pattern = ""
|
pattern = ""
|
||||||
|
@ -28,7 +30,7 @@ while len(arities):
|
||||||
expr.append(arities[-1][1])
|
expr.append(arities[-1][1])
|
||||||
arities.pop()
|
arities.pop()
|
||||||
|
|
||||||
if not exprs and pattern in patterns:
|
if expr and pattern in patterns:
|
||||||
exprs += [pattern, expr]
|
exprs += [pattern, expr]
|
||||||
expr = []
|
expr = []
|
||||||
pattern = ""
|
pattern = ""
|
||||||
|
|
Loading…
Reference in a new issue