File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,10 @@ arglength(a) = length(arguments(a))
1212function < ₑ (a, b)
1313 if a isa Term && (b isa Symbolic && ! (b isa Term))
1414 return false
15- elseif b isa Term && (a isa Symbolic && ! (a isa Term))
15+ elseif b isa Term && (a isa Symbolic && ! (a isa Term))
1616 return true
17+ elseif (a isa Union{Add,Mul}) && (b isa Union{Add,Mul})
18+ return cmp_mul_adds (a, b)
1719 elseif ! istree (a) && ! istree (b)
1820 T = typeof (a)
1921 S = typeof (b)
@@ -27,6 +29,21 @@ function <ₑ(a, b)
2729 end
2830end
2931
32+ function cmp_mul_adds (a, b)
33+ (a isa Add && b isa Mul) && return true
34+ (a isa Mul && b isa Add) && return false
35+ a_args = unsorted_arguments (a)
36+ b_args = unsorted_arguments (b)
37+ length (a_args) < length (b_args) && return true
38+ length (a_args) > length (b_args) && return false
39+ a_args = arguments (a)
40+ b_args = arguments (b)
41+ for (x, y) in zip (a_args, b_args)
42+ x < ₑ y && return true
43+ end
44+ return false
45+ end
46+
3047< ₑ (a:: Symbolic , b:: Sym ) = ! (b < ₑ a)
3148
3249function < ₑ (a:: Symbol , b:: Symbol )
You can’t perform that action at this time.
0 commit comments