turingmachine

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 turingmachine implements postfix calculator using a faster Turing machine.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RPNTuringMachine

func RPNTuringMachine(RPNInput string) float64

RPNTuringMachine returns the result of a string in reverse polish notation (postfix) by using a turing machine. The original band in the words exploded in a slice and results are hold on the band but in num form. The turing band has two copies one in string and one in float. This is mandatory to avoid multiple conversions.

A processed operation or value is erased using ? which is reserved. A calculated value is marked as num which is reserved.

An invalid sign is interpreted as a value and the next operation panics.

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

30.000000
Example (Exp)
fmt.Printf("%.13f", RPNTuringMachine(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