Skip to content

Commit

Permalink
Guard against running Delete[] on an empty list.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Oct 2, 2024
1 parent e3a2e86 commit 582cad5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mathics/builtin/list/eol.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,15 @@ def eval(self, expr, positions, evaluation):
)
return

elements = positions.elements
if len(elements) == 0:
return expr

# Create new python list of the positions and sort it

positions = (
[t for t in positions.elements]
if positions.elements[0].has_form("List", None)
[t for t in elements]
if isinstance(elements[0], ListExpression)
else [positions]
)
positions.sort(key=lambda e: e.get_sort_key(pattern_sort=True))
Expand Down

0 comments on commit 582cad5

Please sign in to comment.