[LON-CAPA-users] More elegant conditional text?

Gerd Kortemeyer lon-capa-users@mail.lon-capa.org
Thu, 7 Feb 2008 21:10:14 -0500

Hi,

On Feb 7, 2008, at 7:46 PM, Ray Batchelor wrote:
>
> <script type="loncapa/perl">$a='$ \mathrm{KE}_1=(1/2)M_1v_1^2 $'; >$b='$\mathrm{E}_2=M_2c^2$';
> $c='$ \mathrm{P}_3=M_3v_3^2 $'; > >$choice=&random(0,2,1);
>
> @array=($a,$b,$c);</script> > <startouttext /><p><m eval="on">$array[$choice] </m></ > p><endouttext /> > > Possibly someone can tell me that this is not robust? I believe it's equally robust. Incorporating Ray's solution, we have four magic incantations: <problem> <script type="loncapa/perl">$array[1] = '<m>$E=mc^2$</m>';
$array[2] = &xmlparse('<m>$\nabla E=\varrho/\varepsilon_0$</m>');$array[3] = '$E=mv^2/2$';
$array[4] = '\nabla\times E=-\partial B/\partial t'; </script> <startouttext /> It is <parse>$array[1]</parse>, but also <display>$array[2]</display> - strange. And there is always <m eval="on">$array[3]</m> and <m eval="on">array[4] \$</m>.
<endouttext />
</problem>

As always in LON-CAPA, the number of possibilities is limitless ...
or at least four.

- Gerd.