Melon Posted April 24, 2014 Author Share Posted April 24, 2014 Nearing the end of last year I was trying to make make an expression evaluator in C# & I can say I failed miserably, you can find it [here](http://indiehub.net/topic/314-c-maths-parser/#entry3866). Last week I decided to retry doing the same thing, this time using [Go](http://golang.org) instead of C#. Features: * Nested Parentheses * Operators: > + - * / ^ ( )* Functions: > Floor Ceil Cbrt Sqrt Sin Cos Tan Asin Acos Atan Abs Ln* Constants: > E Pi Phi Sqrt2 SqrtE SqrtPi SqrtPhiExample:```package mainimport ( "fmt" "gocalc")func main() { exp := gc.NewExpression("9^2+Tan[Pi-X]") exp.AddVariable("X", 1.069) answer := exp.Solve() fmt.Println(answer)}```The source can be found on Github [here](https://github.com/marcmak/gocalc). Link to comment Share on other sites More sharing options...
abhi2011 Posted April 24, 2014 Share Posted April 24, 2014 Always wondered if you could mathematically evaluate strings. Well it seems possible.Nice job. Link to comment Share on other sites More sharing options...
Melon Posted April 25, 2014 Author Share Posted April 25, 2014 Update:I added new functions: Cbrt (Cube Root), Abs (Absolute Value), Ceil, Floor.I also added user defined variables, check the updated example on the first post to see how it works.Any feedback or ideas on features i should add are welcome Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now