Commit Graph

12 Commits

Author SHA1 Message Date
Brandon Amos
22b3e71623 Add stdexcept for domain_error. 2016-02-26 20:51:28 -05:00
Brandon Amos
a6216ecf5d Remove trailing newlines and spaces.
\cc @VinGarcia
2016-02-26 17:50:20 -05:00
Vinícius Garcia
3f80b27bdc Make it accept variable names with numbers, e.g. a1 2016-02-26 01:59:21 -03:00
Vinícius Garcia
9750682c9c Modify calculate() for lazy variable evaluation
Now it is possible to precompile an expression without
binding all its variable values. And bind them only
when the expression will be evaluated.

This way different evaluations of a single expression
may have different sets of variables.

This method optimizes the case when you need to re-evaluate
a single equation several times in different contexts.
2016-02-26 01:24:57 -03:00
Vinícius Garcia
ef5b5d2f22 Add non static functions: compile() and eval()
With this commit the class can now be instantiated.
It now has a constructor and a destructor.

The Compile function will read an expression,
produce an RPN, and save it on this->RPN.

Eval will evaluate this->RPN only when asked for.

The calculator::str() function was added to simplify
the debugging process.
2016-02-26 01:15:08 -03:00
Brandon Amos
9cbaf00a51 Update README. Fix bug with unary operators/operator parsing. 2013-06-21 14:41:14 -07:00
Brandon Amos
9174a0571b Add support for unary operators. 2013-06-21 14:34:49 -07:00
Brandon Amos
f21cf3d1aa Update comments. Refactors to eliminate the ShuntingYard class. 2013-06-21 14:12:55 -07:00
Brandon Amos
eea9c17dd0 Small changes. 2013-06-21 10:57:24 -07:00
Brandon Amos
1d7e56285d Small-scale code refactors, improvements, and comments. 2013-06-21 10:30:40 -07:00
Brandon Amos
652e347e98 Tweak README. Fix imports. 2013-06-11 06:34:01 -07:00
Brandon Amos
c048bb8108 Add test cases and Makefile. 2013-06-11 06:25:37 -07:00