Rename pushback() to concat().

This commit is contained in:
Simon Forman
2018-06-13 10:17:46 -07:00
parent ac56b0f03c
commit 33f34dd15b
2 changed files with 26 additions and 27 deletions
+10 -9
View File
@@ -142,7 +142,7 @@ _s = lambda s: (
)
def pushback(quote, expression):
def concat(quote, expression):
'''Concatinate quote onto expression.
In joy [1 2] [3 4] would become [1 2 3 4].
@@ -155,7 +155,8 @@ def pushback(quote, expression):
# This is the fastest implementation, but will trigger
# RuntimeError: maximum recursion depth exceeded
# on quotes longer than sys.getrecursionlimit().
return (quote[0], pushback(quote[1], expression)) if quote else expression
## return (quote[0], concat(quote[1], expression)) if quote else expression
# Original implementation.
@@ -164,13 +165,13 @@ def pushback(quote, expression):
# In-lining is slightly faster (and won't break the
# recursion limit on long quotes.)
## temp = []
## while quote:
## item, quote = quote
## temp.append(item)
## for item in reversed(temp):
## expression = item, expression
## return expression
temp = []
while quote:
item, quote = quote
temp.append(item)
for item in reversed(temp):
expression = item, expression
return expression