Skip to content

Commit

Permalink
fix for mathics#331
Browse files Browse the repository at this point in the history
  • Loading branch information
sn6uv committed Apr 2, 2016
1 parent 2f10703 commit 0f1c554
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions mathics/builtin/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ def apply(self, expr, evaluation):

items = expr.get_sequence()
result = Symbol('Null')
for expr in items:
result = expr.evaluate(evaluation)
for i, expr in enumerate(items):
term = expr.evaluate(evaluation)
if i == len(items) - 1 and term == Symbol('Null'):
# if the last expression is `Null` then return second last expression
evaluation.quiet_result = True
break
result = term
return result


Expand Down
3 changes: 2 additions & 1 deletion mathics/core/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(self, definitions=None,

self.quiet_all = False
self.quiet_messages = set()
self.quiet_result = False
self.format = format
self.catch_interrupt = catch_interrupt

Expand Down Expand Up @@ -216,7 +217,7 @@ def evaluate():
stored_result = self.get_stored_result(result)
self.definitions.add_rule('Out', Rule(
Expression('Out', line_no), stored_result))
if result != Symbol('Null'):
if not self.quiet_result and result != Symbol('Null'):
return self.format_output(result)
else:
return None
Expand Down

0 comments on commit 0f1c554

Please sign in to comment.