slowturingmachine

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 slowturingmachine implements postfix calculator using a Turing machine using a regular for loop.

Code is Shorter that the fast version of the Turing machine as it is using a "while" format but it remains slower than the usual for structure.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RPNSlowTuringMachine

func RPNSlowTuringMachine(RPNInput string) float64

RPNSlowTuringMachine returns the result of a string in reverse polish notation (postfix) using a Turing machine.

The original band in the words exploded in a slice and results are held on the band but in num form. The band has two copies one in string and one in float. This is mandatory to avoid costly conversions. A processed operation or value is erased by replacing it with ? which is a reserved sign. A calculated value is marked as num which is also a reserved word. An invalid sign is interpreted as a value and the next operation panics.

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

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