Minor cleanup.
This commit is contained in:
parent
2c0a0aafcc
commit
9bb31cbc8a
|
|
@ -313,7 +313,8 @@ printed left-to-right. These functions are written to support :doc:`../pretty`.
|
||||||
|
|
||||||
|
|
||||||
def list_to_stack(el, stack=()):
|
def list_to_stack(el, stack=()):
|
||||||
'''Convert a Python list (or other sequence) to a Joy stack::
|
'''
|
||||||
|
Convert a Python list (or other sequence) to a Joy stack::
|
||||||
|
|
||||||
[1, 2, 3] -> (1, (2, (3, ())))
|
[1, 2, 3] -> (1, (2, (3, ())))
|
||||||
|
|
||||||
|
|
@ -331,7 +332,8 @@ def list_to_stack(el, stack=()):
|
||||||
|
|
||||||
|
|
||||||
def iter_stack(stack):
|
def iter_stack(stack):
|
||||||
'''Iterate through the items on the stack.
|
'''
|
||||||
|
Iterate through the items on the stack.
|
||||||
|
|
||||||
:param stack stack: A stack.
|
:param stack stack: A stack.
|
||||||
:rtype: iterator
|
:rtype: iterator
|
||||||
|
|
@ -342,7 +344,8 @@ def iter_stack(stack):
|
||||||
|
|
||||||
|
|
||||||
def concat(quote, expression):
|
def concat(quote, expression):
|
||||||
'''Concatinate quote onto expression.
|
'''
|
||||||
|
Concatinate quote onto expression.
|
||||||
|
|
||||||
In joy [1 2] [3 4] would become [1 2 3 4].
|
In joy [1 2] [3 4] would become [1 2 3 4].
|
||||||
|
|
||||||
|
|
@ -350,7 +353,7 @@ def concat(quote, expression):
|
||||||
:param stack expression: A stack.
|
:param stack expression: A stack.
|
||||||
:rtype: stack
|
:rtype: stack
|
||||||
'''
|
'''
|
||||||
# This is the fastest implementation, but will trigger
|
# This (below) is the fastest implementation, but will trigger
|
||||||
# RuntimeError: maximum recursion depth exceeded
|
# RuntimeError: maximum recursion depth exceeded
|
||||||
# on quotes longer than sys.getrecursionlimit().
|
# on quotes longer than sys.getrecursionlimit().
|
||||||
# :raises RuntimeError: if quote is larger than sys.getrecursionlimit().
|
# :raises RuntimeError: if quote is larger than sys.getrecursionlimit().
|
||||||
|
|
@ -387,7 +390,9 @@ def get_n_items(n, stack):
|
||||||
try:
|
try:
|
||||||
item, stack = stack
|
item, stack = stack
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise StackUnderflowError('Not enough values on stack.') from None
|
raise StackUnderflowError(
|
||||||
|
'Not enough values on stack.'
|
||||||
|
) from None
|
||||||
temp.append(item)
|
temp.append(item)
|
||||||
temp.append(stack)
|
temp.append(stack)
|
||||||
return tuple(temp)
|
return tuple(temp)
|
||||||
|
|
@ -875,7 +880,9 @@ def rest(stack):
|
||||||
try:
|
try:
|
||||||
_, s1 = s0
|
_, s1 = s0
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise StackUnderflowError('Cannot take rest of empty list.') from None
|
raise StackUnderflowError(
|
||||||
|
'Cannot take rest of empty list.'
|
||||||
|
) from None
|
||||||
return s1, stack
|
return s1, stack
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue