PREP 2013 Question Authoring - Archived

Use of MathObjects

Re: Use of MathObjects

by Davide Cervone -
Number of replies: 0
Actually, there is a special case that I didn't mention, and it is where the Formula is created as an explicit vector, point, or matrix. In that case, the value() method does break up the object into its components, so
    ($f1,$f2,$f3) = Compute("<t,t^2,sin(t)>")->value;
will make $f1 be t, $f2 would be t^2, and $f3 would be sin(t).

This is useful when you are using objects you have created itself, but it would not be wise to use this on student answers, since there is no guarantee that they will have entered a vector in this way (and not as a vector expression). I suppose one could test the class of the top-level node of the expression tree, but it is not clear what you would do if it weren't a Vector.