WeBWorK Main Forum

changing the behavior of Compute

changing the behavior of Compute

by Alex Jordan -
Number of replies: 1
will output

will output

The short version of my question is that I would like this last output to also be "Formula".

I'm working on something where the answer will be a list of function with a Union/Interval/Set. I've got a custom answer checker working pretty well, overriding

However, when the function is a constant function, the class becomes "List", and my checker does not apply. I'd like to have Compute automatically promote things like "1" t be Formula objects, not Real objects. Is that possible?

I can get around the issue by using Formula("1,(-inf,inf)") instead of Compute("1,(-inf,inf)"). But I'm learning more about how Math Objects really work, and I'd like to see if different behavior for Compute is possible.
In reply to Alex Jordan

Re: changing the behavior of Compute

by Davide Cervone -
This is explicitly not what Compute() is designed to do. The purpose of Compute() is to produce the constant object that the formula parses to, if it is constant, and a formula otherwise. If you always want a formula, the correct thing to use is Formula(), not Compute() (as you point out you can do).

Perhaps you can override both the Formula and the List default list-checker?