Right now, the Sum and Product primitives do a little bit of calculation on their own. For example, Sum(<anything>, 0) === <anything>. Unfortunately, this process is already carried out in parse so the user can't intervene:
parse(A + 0) = Variable(A) and parse(A * 1) = Variable(A)
This makes the implicit assumption that 0 is always the identity corresponding to the operator denoted by +, and that 1 is always the identity corresponding to the operator denoted by *.
This assumption doesn't always hold (example).
Can you add an option to parse so that parse(A + 0) come out to be Sum(Variable('A'), 0)?
Right now, the
SumandProductprimitives do a little bit of calculation on their own. For example,Sum(<anything>, 0) === <anything>. Unfortunately, this process is already carried out inparseso the user can't intervene:parse(A + 0) = Variable(A)andparse(A * 1) = Variable(A)This makes the implicit assumption that
0is always the identity corresponding to the operator denoted by+, and that1is always the identity corresponding to the operator denoted by*.This assumption doesn't always hold (example).
Can you add an option to
parseso thatparse(A + 0)come out to beSum(Variable('A'), 0)?