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
16
chainify.py
16
chainify.py
|
@ -1,4 +1,4 @@
|
|||
dyads = "*+-/%"
|
||||
dyads = "*+-/%@"
|
||||
monads = list(map(chr, range(ord("A"), ord("Z") + 1)))
|
||||
nilads = "1234567890"
|
||||
|
||||
|
@ -16,10 +16,12 @@ for char in source:
|
|||
|
||||
exprs = []
|
||||
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 = ""
|
||||
while len(arities):
|
||||
if pattern in patterns:
|
||||
if pattern in patterns and pattern + str(arities[-1][0]) not in patterns:
|
||||
exprs += [pattern, expr]
|
||||
expr = []
|
||||
pattern = ""
|
||||
|
@ -28,9 +30,9 @@ while len(arities):
|
|||
expr.append(arities[-1][1])
|
||||
arities.pop()
|
||||
|
||||
if not exprs and pattern in patterns:
|
||||
exprs += [pattern, expr]
|
||||
expr = []
|
||||
pattern = ""
|
||||
if expr and pattern in patterns:
|
||||
exprs += [pattern, expr]
|
||||
expr = []
|
||||
pattern = ""
|
||||
|
||||
print(exprs)
|
||||
|
|
Loading…
Reference in a new issue