Skip to content
/ eval Public

A simple implementation of Shunting Yard to evaluate infix expressions.

Notifications You must be signed in to change notification settings

aboxofsox/eval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

eval

A simple implementation of Shunting Yard.

Usage

Given an infix expression, eval.Eval(expression) will evaluate the expression using Shunting Yard. The infix expression is converted to Reverse Polish Notation, and then evaluated.

package main

import "github.com/aboxofsox/eval"

func main() {
        exp := "4 * 1024 + 1024" // 5120
        n, err := eval.Eval(exp)
        if err != nil {
                panic(err)
        }
        fmt.Println(n) // 5120
}

About

A simple implementation of Shunting Yard to evaluate infix expressions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages