operatorsnofields

package
v0.0.0-...-40e32b8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package operatorsnofields implements postfix calculator in one loop by editing the string containing the calculation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RPNOperatorsNoFields

func RPNOperatorsNoFields(RPNInput string) float64

RPNOperatorsNoFields returns the result of a sequence of operations written in postfix notation (reverse polish notation).

Each operation is replaced by its result until only a number is left. It fails failing if the expression is invalid. An invalid sign is interpreted as a value and the next operation panics.

The list of operators is searched using package strings. The search avoids to break a second loop but does not provide any major improvement.

Example

if fmt.Print has an output (debug mode)

fmt.Printf("%f", RPNOperatorsNoFields(values.RPNInput))
Output:

30.000000
Example (Exp)
fmt.Printf("%.13f", RPNOperatorsNoFields(values.Input))
Output:

3.0001220703125

Types

This section is empty.

Jump to

Keyboard shortcuts

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