fkleon / math-expressions

A library for parsing and evaluating mathematical expressions, supporting real numbers, vectors, and basic interval arithmetic.
https://pub.dev/packages/math_expressions
MIT License
100 stars 34 forks source link

Implicit multiplication #42

Open creativecreatorormaybenot opened 3 years ago

creativecreatorormaybenot commented 3 years ago

First of all, again: I really appreciate your work on this package ✨

Problem

In mathematics, you can usually write 2x to refer to 2 * x. This is also how e.g. calculators, TeX, etc. handle it.

math_expressions does not seem to be able to handle implicit multiplication.

Using 2x in an expression will throw an exception.

fkleon commented 3 years ago

Yep, this is not supported in the parser at the moment. Will have a look at this for the parser rewrite.

creativecreatorormaybenot commented 3 years ago

@fkleon Super exciting news! 🚀

Let me know if I can be of any help in that regard.

fkleon commented 1 month ago

Support for this has been partially implemented in #87 and #88 by @juca1331. It still requires use of some parentheses (e.g. (2)x) and likely doesn't work for all cases. It's opt-in via parser options. Feel free to have a play with this and leave any feedback here for improvements.