denissimon / formula-parser

Parsing and evaluating mathematical formulas given as strings.
MIT License
76 stars 24 forks source link

FEATURE REQUEST: Custom Functions #10

Closed timothymarois closed 4 years ago

timothymarois commented 4 years ago

It would be useful to have custom functions, I am attempting to mod this, but the parse method isn't exactly built for dynamic customization, it uses exact pre-defined string lengths.

an example like

->addFunction('min', function($value, $arg) {
    return min($value, $arg)
});

While this is a basic example, it would be very useful to have functions passing in the value and a single argument.

denissimon commented 4 years ago

Well, what you're suggesting is a good thing, Timothy, thanks. But, you know, the architecture of this library was designed 6 years ago, and, frankly, now I don’t have time for changing it (and for adding new features in general) due to work in the company. I'm always ready to consider pull requests, though.

timothymarois commented 4 years ago

Well, what you're suggesting is a good thing, Timothy, thanks. But, you know, the architecture of this library was designed 6 years ago, and, frankly, now I don’t have time for changing it (and for adding new features in general) due to work in the company. I'm always ready to consider pull requests, though.

Yeah, I totally understand. I just wanted to put this here in case anyone could figure out the best way to handle this.