silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.19k stars 239 forks source link

Add function assignment #202

Closed eliot-akira closed 5 years ago

eliot-akira commented 5 years ago

The most straight-forward syntax to implement this was f(x) = expression, extending variable assignment. Technically, it does assign something to a variable so it made sense to me.

I ran into a few tricky parts (for example, backtracking in parserState to replace IVAR with IVARNAME) but in the end everything was smoothed out and working well as far as tests go.