[LON-CAPA-cvs] cvs: loncom /html/adm/help/tex Problem_LON-CAPA_Functions.tex /xml lonxml.pm
raeburn
raeburn at source.lon-capa.org
Sat Sep 23 21:52:58 EDT 2017
raeburn Sun Sep 24 01:52:58 2017 EDT
Modified files:
/loncom/xml lonxml.pm
/loncom/html/adm/help/tex Problem_LON-CAPA_Functions.tex
Log:
- Include Math::Calculus::Expression in perl Safe space, to support
parsing of an algebraic expression into a tree structure, followed by
simplificnation (including substitution of named variables etc.).
- Requires perl-Math-Calculus-Expression_loncapa (slightly modified version
of Math::Calculus::Expression from cpan.org).
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.557 loncom/xml/lonxml.pm:1.558
--- loncom/xml/lonxml.pm:1.557 Thu Feb 16 18:17:53 2017
+++ loncom/xml/lonxml.pm Sun Sep 24 01:52:53 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.557 2017/02/16 18:17:53 damieng Exp $
+# $Id: lonxml.pm,v 1.558 2017/09/24 01:52:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,6 +69,7 @@
use Safe::Hole();
use Math::Cephes();
use Math::Random();
+use Math::Calculus::Expression();
use Opcode();
use POSIX qw(strftime);
use Time::HiRes qw( gettimeofday tv_interval );
@@ -819,6 +820,7 @@
$safehole->wrap(\&Apache::functionplotresponse::fpr_objectcoords,$safeeval,'&fpr_objectcoords');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorlength,$safeeval,'&fpr_vectorlength');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorangle,$safeeval,'&fpr_vectorangle');
+ $safehole->wrap(\&Math::Calculus::Expression::math_calculus_expression,$safeeval,'&math_calculus_expression');
# use Data::Dumper;
# $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
Index: loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex
diff -u loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.32 loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.33
--- loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex:1.32 Thu Jan 19 21:12:45 2017
+++ loncom/html/adm/help/tex/Problem_LON-CAPA_Functions.tex Sun Sep 24 01:52:57 2017
@@ -47,6 +47,9 @@
\&format(\$x,'nn') & Display or format \$x as nn where nn is nF or nE or nS and n is an integer. \\
\hline
+
+\$expr=\&math_calculus_expression() & Creates Math::Calculus::Expression object. Methods are: \$expr->addVariable('x'), \$expr->setExpression('f(x)'), \$expr->simplify, \$expr->getExpression -- see Math::Calculus::Expression documentation at cpan.org for details.\\
+\hline
\&prettyprint(\$x,'nn','optional target') & Note that that tag $<$num$>$ can be used to do the same thing. Display or format \$x as nn where nn is nF or nE or nS and n is an integer. Also supports the first character being a \$, it then will format the result with a a call to \&dollarformat() described below. If the first character is a , it will format it with commas grouping the thousands. In S mode it will fromat the number to the specified number of significant figures and display it in F mode. In E mode it will attempt to generate a pretty x10\^{}3 rather than a E3 following the number, the 'optional target' argument is optional but can be used to force \&prettyprint to generate either 'tex' output, or 'web' output, most people do not need to specify this argument and can leave it blank.\\
\hline
More information about the LON-CAPA-cvs
mailing list