Skip to content

Commit

Permalink
sort functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jan 6, 2025
1 parent bbb3664 commit 34966d7
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions mathics/eval/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ def __init__(self, lhs, rhs) -> None:
self.rhs = rhs


def assign_store_rules_by_tag(self, lhs, rhs, evaluation, tags, upset=False) -> bool:
"""
This is the default assignment. Stores a rule of the form lhs->rhs
as a value associated to each symbol listed in tags.
For special cases, such like conditions or patterns in the lhs,
lhs and rhs are rewritten in a normal form, where
conditions are associated to the lhs.
"""
lhs, condition = unroll_conditions(lhs)
lhs, rhs = unroll_patterns(lhs, rhs, evaluation)
defs = evaluation.definitions
ignore_protection, tags = eval_assign_other(self, lhs, rhs, evaluation, tags, upset)
# In WMA, this does not happens. However, if we remove this,
# some combinatorica tests fail.
# Also, should not be at the beginning?
lhs, rhs = process_rhs_conditions(lhs, rhs, condition, evaluation)
count = 0
rule = Rule(lhs, rhs)
position = "up" if upset else None
for tag in tags:
if rejected_because_protected(self, lhs, tag, evaluation, ignore_protection):
continue
count += 1
defs.add_rule(tag, rule, position=position)
return count > 0


def eval_assign(
self,
lhs: BaseElement,
Expand Down Expand Up @@ -94,33 +121,6 @@ def eval_assign(
return False


def assign_store_rules_by_tag(self, lhs, rhs, evaluation, tags, upset=False) -> bool:
"""
This is the default assignment. Stores a rule of the form lhs->rhs
as a value associated to each symbol listed in tags.
For special cases, such like conditions or patterns in the lhs,
lhs and rhs are rewritten in a normal form, where
conditions are associated to the lhs.
"""
lhs, condition = unroll_conditions(lhs)
lhs, rhs = unroll_patterns(lhs, rhs, evaluation)
defs = evaluation.definitions
ignore_protection, tags = eval_assign_other(self, lhs, rhs, evaluation, tags, upset)
# In WMA, this does not happens. However, if we remove this,
# some combinatorica tests fail.
# Also, should not be at the beginning?
lhs, rhs = process_rhs_conditions(lhs, rhs, condition, evaluation)
count = 0
rule = Rule(lhs, rhs)
position = "up" if upset else None
for tag in tags:
if rejected_because_protected(self, lhs, tag, evaluation, ignore_protection):
continue
count += 1
defs.add_rule(tag, rule, position=position)
return count > 0


def eval_assign_attributes(
self: Builtin,
lhs: BaseElement,
Expand Down

0 comments on commit 34966d7

Please sign in to comment.