Documentation ¶
Overview ¶
Common mathematical operations.
Index ¶
- Variables
- func Register(reg func(any))
- type AbsValue
- type AbsValue_Slice
- type AddValue
- type AddValue_Slice
- type CompareNum
- type CompareNum_Slice
- type CompareText
- type CompareText_Slice
- type CompareType
- type CompareValue
- type CompareValue_Slice
- type Comparison
- type Decrement
- type Decrement_Slice
- type DivideValue
- type DivideValue_Slice
- type Increment
- type Increment_Slice
- type ModValue
- type ModValue_Slice
- type MultiplyValue
- type MultiplyValue_Slice
- type SubtractValue
- type SubtractValue_Slice
Constants ¶
This section is empty.
Variables ¶
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
var Zt_AbsValue typeinfo.Flow
abs_value, a type of flow.
var Zt_AddValue typeinfo.Flow
add_value, a type of flow.
var Zt_CompareNum typeinfo.Flow
compare_num, a type of flow.
var Zt_CompareText typeinfo.Flow
compare_text, a type of flow.
var Zt_CompareValue typeinfo.Flow
compare_value, a type of flow.
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{ "--": "Used when comparing values.", }, }
comparison, a type of str enum.
var Zt_Decrement typeinfo.Flow
decrement, a type of flow.
var Zt_DivideValue typeinfo.Flow
divide_value, a type of flow.
var Zt_Increment typeinfo.Flow
increment, a type of flow.
var Zt_ModValue typeinfo.Flow
mod_value, a type of flow.
var Zt_MultiplyValue typeinfo.Flow
multiply_value, a type of flow.
var Zt_SubtractValue typeinfo.Flow
subtract_value, a type of flow.
Functions ¶
Types ¶
type AbsValue ¶
Remove the sign from a value and return its positive value.
func (*AbsValue) GetMarkup ¶
Implements typeinfo.Markup
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 ¶
Add two numbers and return the result.
func (*AddValue) GetMarkup ¶
Implements typeinfo.Markup
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 `json:",omitempty"` }
Compare two numbers.
func (*CompareNum) GetMarkup ¶
func (op *CompareNum) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
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 `json:",omitempty"` }
Compare two text values in "lexical" ( alphabetical ) order.
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 `json:",omitempty"` }
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) 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
Comparison, a type of str enum.
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 `json:",omitempty"` }
Decrease a stored value and, optionally, return the new value.
func (*Decrement) GetMarkup ¶
Implements typeinfo.Markup
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 ¶
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) 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 `json:",omitempty"` }
Increase a stored value and, optionally, return the new value.
func (*Increment) GetMarkup ¶
Implements typeinfo.Markup
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 ¶
Divide one number by another and return the remainder.
func (*ModValue) GetMarkup ¶
Implements typeinfo.Markup
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 `json:",omitempty"` }
Multiply two numbers and return the result.
func (*MultiplyValue) GetMarkup ¶
func (op *MultiplyValue) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
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 `json:",omitempty"` }
Subtract two numbers and return the result.
func (*SubtractValue) GetMarkup ¶
func (op *SubtractValue) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
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.