eval

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2022 License: BSD-3-Clause Imports: 5 Imported by: 1

README

eval

A minimalistic math parser for Go. It implements the shunting-yard-algorithm and allows to parse math from strings.

Work in progress

The current implementation requires spaces between each math token and does not support trigionometric functions yet.

Example

The library can be used as illustrated below:

package main

import (
	"fmt"

	"github.com/jacalz/eval"
)

func main() {
	input := "( 6 - 2 * ( 6 / 3 ) ) ^ 3"
	
	result, err := eval.Evaluate(input)
	if err != nil {
		panic(err)
	}

	fmt.Println(result)
}

A more elaborate example can be found in the example folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evaluate

func Evaluate(input string) (float64, error)

Evaluate evaluates the mathematical expression and returns the result.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL