Documentation
¶
Index ¶
- func Abs[T Numbers](x T) T
- func AsFloat(value int) float64
- func AsString(value int) string
- func Atoi(StrNum string, ResultIfFail int) int
- func CurrentFunction() string
- func DeepCopy(src, dest interface{}) (err error)
- func ErrorIf(condition bool, err error) (noerror error)
- func False[T any](value ...T) bool
- func GenerateFileName(tail string) string
- func Identity[T any](item T) T
- func If[T any](condition bool, value T) (Nil T)
- func IfElse[T any](condition bool, yes T, no T) T
- func IfFalse[T any](condition bool, value T) (Nil T)
- func IsSlice[T any](v T) bool
- func Map[T, R any](function func(T) R, slice []T) (output []R)
- func None[T any](typ_ T) (output T)
- func ParentFunction() string
- func PositiveOrZero[T Numbers](x T) T
- func Regex_CaptureAllAsStrings(input string, regex string) (output []string)
- func Regex_CaptureAsInt(input string, regex string) (output int)
- func Regex_CaptureAsString(input string, regex string) string
- func Regex_Count_Matches(input string, regex string) int
- func Regex_Match(input string, regex string) bool
- func Slice2Map[T2 constraints.Ordered, T1 Indexable[T2]](slice []T1, filter []T2) (out map[T2]T1)
- func True[T any](value T) bool
- func ValueAsFloat(input any) (output float64, err error)
- type Histogram
- type HistogramPlus
- type Indexable
- type MultiString
- type Numbers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Atoi ¶
Atoi converts StrNum to an intenger, returning ResultIfFails if it's not possible. It is equivalent to strconv.Atoi
func GenerateFileName ¶
generate filename in RFC3339 format: 2024-03-07T09:39:22+01:00-world.json
GenerateFileName("-world.json") --> 2024-03-07T09:39:22+01:00-world.json
func Identity ¶
func Identity[T any](item T) T
identity returns its argument
Identity(4) = 4 Identity(true) = true
func Map ¶
func Map[T, R any](function func(T) R, slice []T) (output []R)
Map function to every element of the slice returinng a new slice with the output
Map(abs, []int{-1, 2, -3, 4}) = []int{1, 2, 3, 4}
func None ¶
func None[T any](typ_ T) (output T)
None returns the nil value of T None(4) = 0 None(true) = false
func PositiveOrZero ¶
func PositiveOrZero[T Numbers](x T) T
PositiveOrZero returns the positive number or 0 if negative.
PositiveOrZero(x) = x PositiveOrZero(-x) = 0
func Regex_CaptureAsInt ¶
func Regex_CaptureAsString ¶
func Regex_Count_Matches ¶
func Regex_Match ¶
func Slice2Map ¶
func Slice2Map[T2 constraints.Ordered, T1 Indexable[T2]](slice []T1, filter []T2) (out map[T2]T1)
func ValueAsFloat ¶
1 --> 1.0 1.0 --> 1.0 "1.0" --> 1.0
Types ¶
type Histogram ¶
type Histogram[K comparable] struct { // contains filtered or unexported fields }
Histogram calculates the frequency of value K treating any negative V as zero. So if we remove K when freq(K) == 0 we do not update its frequency.
type HistogramPlus ¶
type HistogramPlus[K comparable] struct { // contains filtered or unexported fields }
HistogramPlus calculates the frequency of value K treating any negative V as negative. So if we remove K when freq(K) == 0 then freq(K) == -1
func (HistogramPlus[K]) Add ¶
func (d HistogramPlus[K]) Add(key K) (NewValue int)
func (HistogramPlus[K]) IsZero ¶
func (d HistogramPlus[K]) IsZero() bool
func (HistogramPlus[K]) Len ¶
func (d HistogramPlus[K]) Len() int
func (HistogramPlus[K]) Remove ¶
func (d HistogramPlus[K]) Remove(key K) (NewValue int)
type Indexable ¶
type Indexable[T constraints.Ordered] interface { Key() (value T, name string) }
type MultiString ¶
type MultiString []string
func Table2MultiLine ¶
func Table2MultiLine(table string) (output MultiString)
convert a list of lines into []string so we can randomly select a line
type Numbers ¶
type Numbers interface { constraints.Float | constraints.Integer }