I’m using these pattern definitions as a second part of determining if the expression inputted is correct. The first part is with simplefunction. I call these definitions later by checking exp.matches().
I’m very unsure about my use of patterns.literal, by the way.
It’ll be really helpful if you share your activity so we can check out your overall code (there may be a simpler solution than pattern matching). Also, we have to assume what solution you’re looking for just based on the code.
I believe literal is exactly what you type so expr3 is looking for 8*a*b*7. (I’m not entirely sure if p.product distinguishes between different orders.)
I created another activity requiring checking of factors. It allowed me to check this one: m²(9m+1)(9m-1), but not this one: 4x(2x+5)(2x-5). So, I wonder if it’s limiting the product to 3 items… Nope, just edited this to say, it seems like it doesn’t like having the literal as part of the product outside of the parentheses.
But I should have been able to do 8a(b-7) because that is just 3. When I put product(product()), it told me not to embed. I’ve resorted to countNumberUsage, for now. Thank you!
I wonder if structuring it where you use a multivaroable function to confirm it’s equivalent to the original but use pattern match in addition more generically (i.e product of 3 expressions) would be a better approach.
Not sure if it’d introduce any false positives/negatives.