math

package
v0.24.6 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Overview

Common mathematical operations.

Index

Constants

This section is empty.

Variables

View Source
var Z_Types = typeinfo.TypeSet{
	Name: "math",
	Comment: []string{
		"Common mathematical operations.",
	},

	Flow:       z_flow_list,
	Str:        z_str_list,
	Signatures: z_signatures,
}

package listing of type data

View Source
var Zt_AbsValue typeinfo.Flow

abs_value, a type of flow.

View Source
var Zt_AddValue typeinfo.Flow

add_value, a type of flow.

View Source
var Zt_CompareNum typeinfo.Flow

compare_num, a type of flow.

View Source
var Zt_CompareText typeinfo.Flow

compare_text, a type of flow.

View Source
var Zt_CompareValue typeinfo.Flow

compare_value, a type of flow.

View Source
var Zt_Comparison = typeinfo.Str{
	Name: "comparison",
	Options: []string{
		"equal_to",
		"other_than",
		"greater_than",
		"less_than",
		"at_least",
		"at_most",
	},
	Markup: map[string]any{
		"comment": "Used when comparing values.",
	},
}

comparison, a type of str enum.

View Source
var Zt_Decrement typeinfo.Flow

decrement, a type of flow.

View Source
var Zt_DivideValue typeinfo.Flow

divide_value, a type of flow.

View Source
var Zt_Increment typeinfo.Flow

increment, a type of flow.

View Source
var Zt_ModValue typeinfo.Flow

mod_value, a type of flow.

View Source
var Zt_MultiplyValue typeinfo.Flow

multiply_value, a type of flow.

View Source
var Zt_SubtractValue typeinfo.Flow

subtract_value, a type of flow.

Functions

This section is empty.

Types

type AbsValue

type AbsValue struct {
	Value  rtti.NumEval
	Markup map[string]any
}

Remove the sign from a value and return its positive value.

func (*AbsValue) GetMarkup

func (op *AbsValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*AbsValue) GetNum

func (op *AbsValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*AbsValue) TypeInfo

func (*AbsValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type AbsValue_Slice

type AbsValue_Slice []AbsValue

Holds a slice of type AbsValue.

func (*AbsValue_Slice) Repeats

func (op *AbsValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of AbsValue.

func (*AbsValue_Slice) TypeInfo

func (*AbsValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of AbsValue.

type AddValue

type AddValue struct {
	A      rtti.NumEval
	B      rtti.NumEval
	Markup map[string]any
}

Add two numbers and return the result.

func (*AddValue) GetMarkup

func (op *AddValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*AddValue) GetNum

func (op *AddValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*AddValue) TypeInfo

func (*AddValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type AddValue_Slice

type AddValue_Slice []AddValue

Holds a slice of type AddValue.

func (*AddValue_Slice) Repeats

func (op *AddValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of AddValue.

func (*AddValue_Slice) TypeInfo

func (*AddValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of AddValue.

type CompareNum

type CompareNum struct {
	A         rtti.NumEval
	Compare   Comparison
	B         rtti.NumEval
	Tolerance float64
	Markup    map[string]any
}

Compare two numbers.

func (*CompareNum) GetBool

func (op *CompareNum) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*CompareNum) GetMarkup

func (op *CompareNum) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*CompareNum) TypeInfo

func (*CompareNum) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type CompareNum_Slice

type CompareNum_Slice []CompareNum

Holds a slice of type CompareNum.

func (*CompareNum_Slice) Repeats

func (op *CompareNum_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of CompareNum.

func (*CompareNum_Slice) TypeInfo

func (*CompareNum_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of CompareNum.

type CompareText

type CompareText struct {
	A       rtti.TextEval
	Compare Comparison
	B       rtti.TextEval
	Markup  map[string]any
}

Compare two text values in "lexical" ( alphabetical ) order.

func (*CompareText) GetBool

func (op *CompareText) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*CompareText) GetMarkup

func (op *CompareText) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*CompareText) TypeInfo

func (*CompareText) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type CompareText_Slice

type CompareText_Slice []CompareText

Holds a slice of type CompareText.

func (*CompareText_Slice) Repeats

func (op *CompareText_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of CompareText.

func (*CompareText_Slice) TypeInfo

func (*CompareText_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of CompareText.

type CompareType

type CompareType int

Flags used compare values

const (
	Compare_EqualTo CompareType = 1 << iota
	Compare_GreaterThan
	Compare_LessThan
)

func (CompareType) CompareBool

func (cmp CompareType) CompareBool(a, b bool) (ret bool)

compare two bools

func (CompareType) CompareFloat

func (cmp CompareType) CompareFloat(a, b, epsilon float64) (ret bool)

compare two floats, within some small tolerance

func (CompareType) CompareInt

func (cmp CompareType) CompareInt(a, b int) bool

compare two integers

func (CompareType) CompareString

func (cmp CompareType) CompareString(a, b string) bool

compare two strings

func (CompareType) String

func (i CompareType) String() string

type CompareValue

type CompareValue struct {
	A       rtti.Assignment
	Compare Comparison
	B       rtti.Assignment
	Markup  map[string]any
}

Compare two values. If the two values are of different types, this will attempt -- in a limited way -- to coerce the second value to match the type of the first value before comparing them.

Any value can be coerced to bool ( following the truthiness rules for [IsValue] ), and bool and num values can be coerced into text. Otherwise, the types of the values must match exactly.

Numbers are compared using an internally determined default tolerance. To control the tolerance between numbers, use CompareNum.

func (*CompareValue) GetBool

func (op *CompareValue) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*CompareValue) GetMarkup

func (op *CompareValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*CompareValue) TypeInfo

func (*CompareValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type CompareValue_Slice

type CompareValue_Slice []CompareValue

Holds a slice of type CompareValue.

func (*CompareValue_Slice) Repeats

func (op *CompareValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of CompareValue.

func (*CompareValue_Slice) TypeInfo

func (*CompareValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of CompareValue.

type Comparison

type Comparison int

Used when comparing values.

const (
	C_Comparison_EqualTo Comparison = iota
	C_Comparison_OtherThan
	C_Comparison_GreaterThan
	C_Comparison_LessThan
	C_Comparison_AtLeast
	C_Comparison_AtMost
)

The enumerated values of Comparison.

func MakeComparison

func MakeComparison(str string) (ret Comparison, okay bool)

func (Comparison) Compare

func (op Comparison) Compare() (ret CompareType)

return flags to help compare numbers

func (Comparison) String

func (op Comparison) String() (ret string)

type Decrement

type Decrement struct {
	Target rtti.Address
	Step   rtti.NumEval
	Markup map[string]any
}

Decrease a stored value and, optionally, return the new value.

func (*Decrement) Execute

func (op *Decrement) Execute(run rt.Runtime) (err error)

func (*Decrement) GetMarkup

func (op *Decrement) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Decrement) GetNum

func (op *Decrement) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*Decrement) TypeInfo

func (*Decrement) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Decrement_Slice

type Decrement_Slice []Decrement

Holds a slice of type Decrement.

func (*Decrement_Slice) Repeats

func (op *Decrement_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Decrement.

func (*Decrement_Slice) TypeInfo

func (*Decrement_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Decrement.

type DivideValue

type DivideValue struct {
	A      rtti.NumEval
	B      rtti.NumEval
	Markup map[string]any
}

Divide one number by another and return the result.

func (*DivideValue) GetMarkup

func (op *DivideValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*DivideValue) GetNum

func (op *DivideValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*DivideValue) TypeInfo

func (*DivideValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type DivideValue_Slice

type DivideValue_Slice []DivideValue

Holds a slice of type DivideValue.

func (*DivideValue_Slice) Repeats

func (op *DivideValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of DivideValue.

func (*DivideValue_Slice) TypeInfo

func (*DivideValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of DivideValue.

type Increment

type Increment struct {
	Target rtti.Address
	Step   rtti.NumEval
	Markup map[string]any
}

Increase a stored value and, optionally, return the new value.

func (*Increment) Execute

func (op *Increment) Execute(run rt.Runtime) (err error)

func (*Increment) GetMarkup

func (op *Increment) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Increment) GetNum

func (op *Increment) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*Increment) TypeInfo

func (*Increment) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Increment_Slice

type Increment_Slice []Increment

Holds a slice of type Increment.

func (*Increment_Slice) Repeats

func (op *Increment_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Increment.

func (*Increment_Slice) TypeInfo

func (*Increment_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Increment.

type ModValue

type ModValue struct {
	A      rtti.NumEval
	B      rtti.NumEval
	Markup map[string]any
}

Divide one number by another and return the remainder.

func (*ModValue) GetMarkup

func (op *ModValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ModValue) GetNum

func (op *ModValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*ModValue) TypeInfo

func (*ModValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ModValue_Slice

type ModValue_Slice []ModValue

Holds a slice of type ModValue.

func (*ModValue_Slice) Repeats

func (op *ModValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ModValue.

func (*ModValue_Slice) TypeInfo

func (*ModValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ModValue.

type MultiplyValue

type MultiplyValue struct {
	A      rtti.NumEval
	B      rtti.NumEval
	Markup map[string]any
}

Multiply two numbers and return the result.

func (*MultiplyValue) GetMarkup

func (op *MultiplyValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*MultiplyValue) GetNum

func (op *MultiplyValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*MultiplyValue) TypeInfo

func (*MultiplyValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type MultiplyValue_Slice

type MultiplyValue_Slice []MultiplyValue

Holds a slice of type MultiplyValue.

func (*MultiplyValue_Slice) Repeats

func (op *MultiplyValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of MultiplyValue.

func (*MultiplyValue_Slice) TypeInfo

func (*MultiplyValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of MultiplyValue.

type SubtractValue

type SubtractValue struct {
	A      rtti.NumEval
	B      rtti.NumEval
	Markup map[string]any
}

Subtract two numbers and return the result.

func (*SubtractValue) GetMarkup

func (op *SubtractValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*SubtractValue) GetNum

func (op *SubtractValue) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*SubtractValue) TypeInfo

func (*SubtractValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type SubtractValue_Slice

type SubtractValue_Slice []SubtractValue

Holds a slice of type SubtractValue.

func (*SubtractValue_Slice) Repeats

func (op *SubtractValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of SubtractValue.

func (*SubtractValue_Slice) TypeInfo

func (*SubtractValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of SubtractValue.

Jump to

Keyboard shortcuts

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