## WeBWorK Main Forum

### changing the behavior of Compute

by Alex Jordan -
Number of replies: 1
With
$a=Compute("x,(-inf,inf)") then TEXT($a->class)
will output
"Formula"

With
$b=Compute("1,(-inf,inf)") then TEXT($b->class)
will output
"List"

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
\$context->{cmpDefaults}{Formula}{list_checker}

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.
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).