Can pattern matching operate on a latex string that’s defined as a variable in the script? I’ve created a string called “Combined_Student_Numerators”, which is generated in the script. It pulls apart the student input and multiplies all the quantities that are in the numerator of the student’s expression, allowing me to treat these as equivalent:
(3x^2)/5
(3/5)*x^2
3x^2*(1/5)
etc
(In all three cases above, Combined_Student_Numerators would be 3*x^2, regardless of where the student chose to put the 1/5)
Combined_Student_Numerators =
when WhichProduct=1 "${T1_Num}"
when WhichProduct=2 "${T1_Num}\cdot ${T2_Num}"
when WhichProduct=3 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}`"
when WhichProduct=4 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}\cdot ${T4_Num}`"
when WhichProduct=5 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}\cdot ${T4_Num}\cdot ${T5_Num}`"
when WhichProduct=6 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}\cdot ${T4_Num}\cdot ${T5_Num}\cdot ${T6_Num}`"
when WhichProduct=7 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}\cdot ${T4_Num}\cdot ${T5_Num}\cdot ${T6_Num}\cdot ${T7_Num}`"
when WhichProduct=8 "`${T1_Num}\cdot ${T2_Num}\cdot ${T3_Num}\cdot ${T4_Num}\cdot
otherwise "Error"
Now I need to run pattern-matching on Combined_Student_Numerators. It doesn’t seem to work. It does work if I make Combined_Student_Numerators the initialLatex of a math input and then parse that input. But then it doesn’t update if the student changes their answer, I guess because initialLatex just defines a starting state but doesn’t update.