This function would receive an expression and return a boolean indicating whether the expression is valid.
The use case for this is that it should be significantly faster than eval since we don't have to evaluate anything. In particular, we wouldn't need to call parse which is the slowest part of eval.
We can try to use something like the Mode pattern described here to avoid code duplication between eval and check.
This function would receive an expression and return a boolean indicating whether the expression is valid.
The use case for this is that it should be significantly faster than
eval
since we don't have to evaluate anything. In particular, we wouldn't need to callparse
which is the slowest part ofeval
.We can try to use something like the
Mode
pattern described here to avoid code duplication betweeneval
andcheck
.