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 1d8d047
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 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("")
2 changes: 1 addition & 1 deletion mathics/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(
"NONE": (["", "", "", ""], ["", "", "", ""]),
"LINUX": (
["\033[32m", "\033[1m", "\033[0m\033[32m", "\033[39m"],
["\033[31m", "\033[1m", "\033[0m\033[31m", "\033[39m"],
["\033[31m", "\033[1m", "\033[0m\033[32m", "\033[39m"],
),
"LIGHTBG": (
["\033[34m", "\033[1m", "\033[22m", "\033[39m"],
Expand Down

0 comments on commit 1d8d047

Please sign in to comment.