Open evykassirer opened 7 years ago
so this happens in performTermOperationOnExpression
in EquationOperations.js
we should add parenthesis if the operator is /
or *
or ^
e.g. 2y = 2x + 2 => y = (2x + 2) / 2
we should not though, if the operator is +
or -
, because we don't need parens to add/subtract to both sides
this should be a change that's only a few lines :)
I'm working on this!
RACHEL! 😸 ❤️
excited to have you contributing
@evykassirer are the parens necessary for the /
, *
, and ^
? Wouldn't the following expression tree:
{
type: "OperationNode",
op: "/",
args: [
{
type: "OperationNode",
op: "+",
args: [
{ type: SymbolNode, name: "x" },
{ type: ConstantNode, value: "2" }
],
},
{ type: ConstantNode, value: "2" }
]
}
render as (x + 2) / 2
?
it does when you print it with .toString()
but not with our handmade print()
(I think?) (which was made before we were able to use toString()
I kind of like the idea of knowing exactly where parens are, especially because sometimes we explicitly add them for pedagogy reasons (e.g. (x + x) + (2 + 2)
) but maybe we could consider having a smarter print function and not as many parens in the tree. What do you think?
(I'm okay with this change going in for now though)
(conversation about print
continued in #126 )
as discussed in #90 (thanks @arve0 !)