Comments (4)
Thanks @tomotom , i'll check more that example.
The intention was to provide a sample with dynamic arguments count, as "sum" is already defined into php core.
from matex.
Hi Madorin, This threw me a bit also. I was trying to call generic php math functions, like max() with your syntax. PHP Math functions: http://php.net/manual/en/ref.math.php
I finally got it to work, but I wasn't sure about the Object or what your 'ref' and 'arc' keys were until I studied your script a bit more. So a suggestion would be 1.) an explanation of how function arrays work and are set. 2.) Including PHP's arithmetic functions by default. Thank you for a great script! It is very handy and concise! I plan to study it in more detail and learn from it.
from matex.
@nuntius-rex, thanks for suggestions, i'll try to document then better example and source code.
The idea was to not overload engine itself by adding functions that you are not going to use.
We had projects where we need to do just sum and some our custom, no sin, cos etc...
About parameters:
ref - function name [including namespace, class | object etc..]
arc - argument count, if null - any number, unknown
Theoretically all math functions can be included automatically by having a special PHP file that add math function to Evaluator class.
from matex.
Thanks @madorin I can appreciate the desire to keep things concise, clean and minimal. It's definitely best practice. I am also just adding what I need. Thank you for the clarification on the parameters.
from matex.
Related Issues (20)
- Code can't handle round brackets in strings
- Example given does't work
- Can't handle negative numbers HOT 1
- Rounding HOT 1
- Custom basic operators HOT 1
- Composer not installing for my PHP version. HOT 3
- Assign a value to a variable inside an expression HOT 3
- Exception: Empty argument in Evaluator->addArgument() when custom function without arguments HOT 4
- Order of operations between powers and multiplications HOT 5
- Support zero float point variables (x =>0.1)
- Problem calcul simple addition HOT 2
- Double-byte characters such as * are not available
- Could not evaluate "2*0*0.45*0.3*7.4999999999999997E-2"
- Not working with multiples of 10
- Add composer.json and add this to https://packagist.org/ HOT 7
- Make variables case sensitive (not only Lower Case) HOT 3
- Support comparison operators (>, <, =, >=,<=) to get a true / false evaluation HOT 4
- ( 101.25 + -202.44 ) results in "syntax error"
- Handle invalid operations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matex.