package
0.0.0-20241020204346-852d83918761
Repository: https://github.com/plutov/practice-go.git
Documentation: pkg.go.dev
# README
Calculator
Create a calculator that can evaluate simple mathematical expressions. The calculator should be able to handle the basic arithmetic operations: addition, subtraction, multiplication, and division.
Function
Eval(expr string) (float64, error)
Examples
result, err := Eval("1 + 2")
fmt.Println(result) // 3
result, err := Eval("2 * 3")
fmt.Println(result) // 6
result, err := Eval("10 / 2 + 6")
fmt.Println(result) // 11
result, err := Eval("( 2 + 3 ) * 4")
fmt.Println(result) // 20
Run tests with benchmarks
go test -bench .
# Functions
No description provided by the author
Evaluate an expression which is guaranteed to contain no brackets.
Tokenise the input string.
# Type aliases
An AlgebraicSymbol is one of the four algebraic operators, or a bracket.