Skip to content

Go library for parsing and evaluating mathematical expression

License

Notifications You must be signed in to change notification settings

darylnwk/postfix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

postfix

-- import "github.com/darylnwk/postfix"

Usage

func Evaluate

func Evaluate(postfix Postfix, variables map[string]float64) float64

Evaluate takes Postfix and a map of variables and returns the result of the expression See https://en.wikipedia.org/wiki/Reverse_Polish_notation#Postfix_evaluation_algorithm for more details.

type Postfix

type Postfix []mathtoken.Token

Postfix defines a list of tokens

func ParseInfix

func ParseInfix(infix string) (postfix Postfix, err error)

ParseInfix parses a mathematical expression in infix notation to postfix notation (or RPN) using Shunting-yard algorithm. See https://en.wikipedia.org/wiki/Shunting-yard_algorithm#The_algorithm_in_detail for more details.

About

Go library for parsing and evaluating mathematical expression

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages