[LON-CAPA-cvs] cvs: loncom /homework lonmaxima.pm

raeburn raeburn at source.lon-capa.org
Sun Jun 11 20:22:36 EDT 2017


raeburn		Mon Jun 12 00:22:36 2017 EDT

  Modified files:              
    /loncom/homework	lonmaxima.pm 
  Log:
  - Improve regexp used to convert pi to %pi in &maxima_cas_formula_fix().
    - Conversion if pi is at the beginning or at the end of the string.
    - Exclude conversion if pi is the first part of a variable name (e.g., pie).
  
  
Index: loncom/homework/lonmaxima.pm
diff -u loncom/homework/lonmaxima.pm:1.37 loncom/homework/lonmaxima.pm:1.38
--- loncom/homework/lonmaxima.pm:1.37	Tue Mar  7 18:28:02 2017
+++ loncom/homework/lonmaxima.pm	Mon Jun 12 00:22:35 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to MAXIMA CAS
 #
-# $Id: lonmaxima.pm,v 1.37 2017/03/07 18:28:02 raeburn Exp $
+# $Id: lonmaxima.pm,v 1.38 2017/06/12 00:22:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,7 +118,7 @@
 sub maxima_cas_formula_fix {
    my ($expression)=@_;
    $expression=&Apache::response::implicit_multiplication($expression);
-   $expression=~s/([^\w\%])pi/$1\%pi/gs;
+   $expression=~s/(^|[^\w\%])pi(\W|$)/$1\%pi$2/gs;
    return $expression;
 }
 




More information about the LON-CAPA-cvs mailing list