WeBWorK Problems

Arbitrary constants in $f->cmp

Arbitrary constants in $f->cmp

by Richard Litherland -
Number of replies: 4
If $f is a Formula, is there any way to make $f->cmp do comparison up to an arbitrary constant? You can use fun_cmp($f, mode=>"antider"), but this loses any advantage of $f->cmp over fun_cmp.
In reply to Richard Litherland

Re: Arbitrary constants in $f->cmp

by Davide Cervone -
Sure. Use
  ANS($f->cmp(upToConstant=>1));
to get the equivalent of mode=>"antidir".

There is also a MathObject for formulas-up-to-constants that requires the student to include the constant (and they can pick any constant they want, not just "C"). See the documentation for

    pg/macros/parserFormulaUpToConstant.pl
at
    http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/parserFormulaUpToConstant.pl.html
for details on how to use it.

Davide

In reply to Davide Cervone

Re: Arbitrary constants in $f->cmp

by Richard Litherland -
Many thanks. I'm still having trouble finding my way around the documentation, and the upToConstant flag doesn't seem to be mentioned in http://webwork.maa.org/doc/cvs/pg_CURRENT/doc/MathObjects/MathObjectsAnswerCheckers.html. Do you know where it's documented? Rick.
In reply to Richard Litherland

Re: Arbitrary constants in $f->cmp

by Davide Cervone -
The MathObjectsAnswerCheckers.html file is a very early document that I wrote when I first developed the MathObjects library, and it hasn't been updated very well as changes have been made. So it is pretty our of date. (It's not actually WRONG, but sadly incomplete.) The documentation situation is pretty poor all around.

It should have been in

http://webwork.maa.org/doc/cvs/pg_CURRENT/lib/Value/AnswerChecker.html

but seems to have been left out (none of the Formula flags are listed). I'm afraid I usually just look at the code when someone asks me what the flags are. :-)

Davide