Skip to content

Commit 61a858b

Browse files
committed
fix clear
1 parent e9f4eaa commit 61a858b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

mathics/builtin/assignment.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,27 @@ def do_clear(self, definition):
10661066

10671067
def apply(self, symbols, evaluation):
10681068
'%(name)s[symbols___]'
1069-
1070-
for symbol in symbols.get_sequence():
1069+
if isinstance(symbols ,Symbol):
1070+
symbols = [symbols]
1071+
elif isinstance(symbols, Expression):
1072+
symbols = symbols.get_leaves()
1073+
elif isinstance(symbols ,String):
1074+
symbols = [symbols]
1075+
else:
1076+
symbols = symbols.get_sequence()
1077+
1078+
for symbol in symbols:
10711079
if isinstance(symbol, Symbol):
10721080
names = [symbol.get_name()]
10731081
else:
10741082
pattern = symbol.get_string_value()
10751083
if not pattern:
10761084
evaluation.message('Clear', 'ssym', symbol)
10771085
continue
1086+
if pattern[0] == "`":
1087+
pattern = (evaluation.definitions.get_current_context()
1088+
+ pattern[1:])
1089+
10781090
names = evaluation.definitions.get_matching_names(pattern)
10791091
for name in names:
10801092
attributes = evaluation.definitions.get_attributes(name)

0 commit comments

Comments
 (0)