2017 © Pedro Peláez
 

library lib-beeme

Simple mathematical expression/equation parser and calculator.

image

webfactorybulgaria/lib-beeme

Simple mathematical expression/equation parser and calculator.

  • Friday, September 30, 2016
  • by webfactorybulgaria
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Beeme (Basic Equation/Expression Math Engine)

Simple mathematical expression parser and calculator based on the great work of Adrean Boyadzhiev., (*1)

Install

The recommended way to install Beeme is through composer., (*2)

{
    "require": {
        "oat-sa/lib-beeme": "dev-master"
    }
}

Basic Usage

Here is an simple example of evaluation of mathematical expression, (*3)

<?php

$parser = new \oat\beeme\Parser();
$expression = '1 + 2 * 3 * ( 7 * 8 ) - ( 45 - 10 )';
$result = $parser->evaluate($expression);

echo $result; // 302.000000

Constants

Beeme comes with two built-in constants that are "pi" and "e". You can also use custom constans in your expressions, and give them actual values at runtime. Below, an example with the constant "x" replaced by the integer value 3., (*4)

<?php

$parser = new \oat\beeme\Parser();
$expression = '3 + x';
$result = $parser->evaluate(
    $expression,
    ['x' => 3]
);

echo $result; // 6.000000

Functions

Beeme provides a set of unary functions to be used in your expressions. Below is an example of using the "abs" function in an expression., (*5)

<?php

$expression = '1 + abs(x)';
$result = $parser->evaluate(
    $expression,
    ['x' => -10]
);

echo $result; // 11.000000

Please see the list of available unary functions available in Beeme. They all map to their PHP built-in equivalent:, (*6)

TODO

  • Always more unit tests
  • N-ary functions

License

MIT, see LICENSE., (*7)

The Versions

30/09 2016

dev-master

9999999-dev

Simple mathematical expression/equation parser and calculator.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Adrean Boyadzhiev

math parser shunting-yard algorithm math calculator

12/07 2016

dev-develop

dev-develop

Simple mathematical expression/equation parser and calculator.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Adrean Boyadzhiev

math parser shunting-yard algorithm math calculator

12/07 2016

0.1.0

0.1.0.0

Simple mathematical expression/equation parser and calculator.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Adrean Boyadzhiev

math parser shunting-yard algorithm math calculator

05/04 2016

0.0.0

0.0.0.0

Simple mathematical expression/equation parser and calculator.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Adrean Boyadzhiev

math parser shunting-yard algorithm math calculator