[system] / trunk / pg / macros / parserFormulaUpToConstant.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/parserFormulaUpToConstant.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5673 Revision 5896
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/macros/parserFormulaUpToConstant.pl,v 1.10 2007/10/04 16:40:48 sh002i Exp $ 4# $CVSHeader: pg/macros/parserFormulaUpToConstant.pl,v 1.11.2.1 2008/06/24 00:44:54 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
173 # 173 #
174 $r = $r->substitute($r->{constant}=>$l->{constant}) unless $r->{constant} eq $l->{constant}; 174 $r = $r->substitute($r->{constant}=>$l->{constant}) unless $r->{constant} eq $l->{constant};
175 # 175 #
176 # Compare with adaptive parameters to see if $l + n0 C = $r for some n0. 176 # Compare with adaptive parameters to see if $l + n0 C = $r for some n0.
177 # 177 #
178 $main::_cmp_ = sub {return $l->{adapt} == $r}; # a closure to access local variables 178 $main::{_cmp_} = sub {return $l->{adapt} == $r}; # a closure to access local variables
179 my $equal = main::PG_restricted_eval('&$_cmp_'); # prevents errors with large adaptive parameters 179 my $equal = main::PG_restricted_eval('&{$main::{_cmp_}}'); # prevents errors with large adaptive parameters
180 delete $main::{_cmp_}; # remove temprary function 180 delete $main::{_cmp_}; # remove temprary function
181 return -1 unless $equal; 181 return -1 unless $equal;
182 # 182 #
183 # Check that n0 is non-zero (i.e., there is a multiple of C in the student answer) 183 # Check that n0 is non-zero (i.e., there is a multiple of C in the student answer)
184 # (remember: return value of 0 is equal, and non-zero is unequal) 184 # (remember: return value of 0 is equal, and non-zero is unequal)
185 # 185 #

Legend:
Removed from v.5673  
changed lines
  Added in v.5896

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9