## WeBWorK Problems

### Creating a List from a MathObject tree

by Jaimos Skriletz -
Number of replies: 1

I am looking for a way to parse the MathObject tree and create a list for a given outer most operation (though my use case is currently + and -).

For instance I want to take a student answer of the form A+B+C+D and turn it into a List (A,B,C,D) that I can compare to an answer key (either ordered or unordered).

The use case I have for this is partial fractions and Taylor polynomials, in which I want to compare their answers as if it were a list of terms. I do know partial fractions can mostly be done with bizarroArithmetic.pl and Taylor polynomials withcontextLimitedPolynomial.pl (though this doesn't have an option to force the order of addition which I will sometimes want to do). But I find limitations with both where just being able to get a list of terms would be useful to me. (Also be nice if this were a bit more general so I could also use it to get a list of factors with the operation * and /).

I have attempted this, but I get lost in the tree after a single operation, so I have been able to turn A+B into a list, but have trouble with A+B+C depending on how I group it, (A+B)+C vs A+(B+C).

Thanks in advanced for any suggestions on how to get a list of terms or factors from a students answer.