Documentation ¶
Index ¶
- Variables
- func As[T xmath.Numeric](value Int) T
- func NewEvaluator(resolver eval.VariableResolver) *eval.Evaluator
- func ResetIfOutOfRangeInt(value, min, max, def int) int
- type DP
- type Fraction
- type Int
- func ApplyRounding(value Int, roundDown bool) Int
- func EvaluateToNumber(expression string, resolver eval.VariableResolver) Int
- func Extract(in string) (value Int, remainder string)
- func From[T xmath.Numeric](value T) Int
- func FromString(value string) (Int, error)
- func FromStringForced(value string) Int
- func ResetIfOutOfRange(value, min, max, def Int) Int
Constants ¶
This section is empty.
Variables ¶
var ( EvalOperators = eval.FixedOperators[DP](true) EvalFuncs = eval.FixedFunctions[DP]() )
The evaluator operators and functions that will be used when calling NewEvaluator().
var ( Min = Int(f64.Min) NegPointEight = FromStringForced("-0.8") Quarter = FromStringForced("0.25") Half = FromStringForced("0.5") One = From(1) OneAndAHalf = FromStringForced("1.5") Two = From(2) Three = From(3) Four = From(4) Five = From(5) Six = From(6) Seven = From(7) Eight = From(8) Nine = From(9) Ten = From(10) Twelve = From(12) Fifteen = From(15) Nineteen = From(19) Twenty = From(20) TwentyFour = From(24) ThirtySix = From(36) Thirty = From(30) Forty = From(40) Fifty = From(50) Seventy = From(70) Eighty = From(80) NinetyNine = From(99) Hundred = From(100) Thousand = From(1000) MaxBasePoints = From(999999) Max = Int(f64.Max) )
Common values that can be reused.
Functions ¶
func NewEvaluator ¶
func NewEvaluator(resolver eval.VariableResolver) *eval.Evaluator
NewEvaluator creates a new evaluator whose number type is an Int.
func ResetIfOutOfRangeInt ¶
ResetIfOutOfRangeInt checks the value and if it is lower than min or greater than max, returns def, otherwise returns value.
Types ¶
type Fraction ¶
Fraction is an alias for the fixed-point fractional type we are using.
func NewFraction ¶
NewFraction creates a new fractional value from a string.
type Int ¶
Int is an alias for the fixed-point type we are using.
func ApplyRounding ¶
ApplyRounding rounds in the positive direction of roundDown is false, or in the negative direction if roundDown is true.
func EvaluateToNumber ¶
func EvaluateToNumber(expression string, resolver eval.VariableResolver) Int
EvaluateToNumber evaluates the provided expression and returns a number.
func Extract ¶
Extract a leading value from a string. If a value is found, it is returned along with the portion of the string that was unused. If a value is not found, then 0 is returned along with the original string.
func FromString ¶
FromString creates an Int from a string.
func FromStringForced ¶
FromStringForced creates an Int from a string, ignoring any conversion inaccuracies.
func ResetIfOutOfRange ¶
ResetIfOutOfRange checks the value and if it is lower than min or greater than max, returns def, otherwise returns value.