RE: [PEAR-DEV] Package Proposal: Math_RPN

From: Date: Wed, 11 Jun 2003 06:55:09 +0000
Subject: RE: [PEAR-DEV] Package Proposal: Math_RPN
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17294@lists.php.net to get a copy of this message
Hi, Looks good. I have on remark, for some reason i don't like the calculate() method, could you provide an evaluate() method as an alias ? I use RPN for logic-based rules so calculate does not make much sense where evaluate does. I ask that for readability, i find it easier to understand evaluate than calculate. I would also change the comment at the top of the file. Change Expression To RPN (Reverse Polish Notation), Calculate RPN Expression to Change Expression To RPN (Reverse Polish Notation), Evaluate RPN Expression Math_RPN is a good name. Arnaud. > Hi, > > I changed the addOperator() function. Now you can add > function name (or > class name and function name) as parameter. > So, for example: > > <?php > > include('Math/Rpn.php'); > $rpn = new Math_Rpn(); > > function mysign($number) { > return ($number >=0 ) ? 1 : -1; > } > > class random { > function mysum($a,$b) { > return $a + $b; > } > } > > $rpn->addOperator('sum','random::mysum',3,2,'sum [user > class]'); > ^^^^^^^^^^^ > $rpn->addOperator('sign','mysign',3,1,'sign [user function]'); > ^^^^^ > > $input = 'sign((3 sum 2)*(7-sin(30)*log(10)))'; > $value = $rpn->calculate($input,'deg',false); > > ?> > > What do you think about it? > > New version is here -> > http://www.maciek.maribex.wizja.net.pl/rpn/ > > Regards, > Maciek admin@e-rower.pl > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pear.dev (#17294) next »