Skip to content

Commit

Permalink
Add one more case of two-arg FileDrop ...
Browse files Browse the repository at this point in the history
with negative args
  • Loading branch information
rocky committed Oct 22, 2024
1 parent 0258ba4 commit 223296b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions mathics/builtin/file_operations/path_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ def eval_with_n_to_m(
# Not sure why this is so.
return String(osp.join(*path_elts[:-1]))
return path
evaluation.message("FindNameDrop", "notfinished")
return None

# if n_pos > path_len:
# return path

# new_elts = None
# if 0 < n_pos < m_pos:
# new_elts = path_elts[n_pos+1: m_pos+2]
# if new_elts:
# return String(osp.join(*new_elts))s
# else:
# return String("")

if n_pos > m_pos:
return path

new_elts = None
if 0 < n_pos < m_pos:
new_elts = path_elts[: n_pos - 1] + path_elts[m_pos:]
elif n_pos <= m_pos <= 0:
new_elts = path_elts[:n_pos] + path_elts[m_pos + 1 :]
else:
evaluation.message("FindNameDrop", "notfinished")
return None

if new_elts:
return String(osp.join(*new_elts))
else:
return String("")

0 comments on commit 223296b

Please sign in to comment.