core

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotZeroOrPositive = errors.New("numbers must be zero or positive")
	ErrNotInList         = errors.New("element not in list")
	ErrListEmpty         = errors.New("list is empty")
	ErrTypeNotSupported  = errors.New("type not supported")
)

Error variables that are common within the module

Functions

func AppendFloat32

func AppendFloat32(array []float32, element float32) []float32

AppendFloat32 : implements append

func AppendFloat64

func AppendFloat64(array []float64, element float64) []float64

AppendFloat64 : implements append

func AppendInt

func AppendInt(array []int, element int) []int

AppendInt : implements append

func AppendInt32

func AppendInt32(array []int32, element int32) []int32

AppendInt32 : implements append

func AppendInt64

func AppendInt64(list []int64, element int64) []int64

AppendInt64 : implements append

func AppendString

func AppendString(array []string, element string) []string

AppendString : implements append

func CombinationsString added in v1.1.6

func CombinationsString(set []string, n int, joiner string) (subsets []string)

CombinationsString : adapted from https://github.com/mxschmitt/golang-combinations

func CombinationsStringMax added in v1.3.0

func CombinationsStringMax(set []string, n int, joiner string) (subsets []string)

CombinationsStringMax returns combinations of max length. For example: a list of [a, b, c] with max combination 2, should return 1 and 2 combinations. i.e combinations length <= n adapted from https://github.com/mxschmitt/golang-combinations

func ConvertToFloat32 added in v1.4.0

func ConvertToFloat32(array interface{}) (Intify []float32, err error)

ConvertToFloat32 converts to slice to float32

func ConvertToFloat64 added in v1.4.0

func ConvertToFloat64(array interface{}) (Intify []float64, err error)

ConvertToFloat64 converts to slice to float64

func ConvertToInt added in v1.4.0

func ConvertToInt(array interface{}) (Intify []int, err error)

ConvertToInt converts to slice to int

func ConvertToInt32 added in v1.4.0

func ConvertToInt32(array interface{}) (Intify []int32, err error)

ConvertToInt32 converts to slice to int32

func ConvertToInt64 added in v1.4.0

func ConvertToInt64(array interface{}) (Intify []int64, err error)

ConvertToInt64 converts to slice to int64

func ConvertToString added in v1.4.0

func ConvertToString(array interface{}) (stringfy []string, err error)

ConvertToString converts to a specified list type

func CountFloat32

func CountFloat32(list *[]float32, element float32) int

CountFloat32 : returns the number of times a given element appears in a slice

func CountFloat64

func CountFloat64(list *[]float64, element float64) int

CountFloat64 : returns the number of times a given element appears in a slice

func CountInt

func CountInt(list *[]int, element int) int

CountInt : returns the number of times a given element appears in a slice

func CountInt32

func CountInt32(list *[]int32, element int32) int

CountInt32 : returns the number of times a given element appears in a slice

func CountInt64

func CountInt64(list *[]int64, element int64) int

CountInt64 : returns the number of times a given element appears in a slice

func CountString

func CountString(list *[]string, element string) int

CountString : returns the number of times a given element appears in a slice

func ExtendFloat32

func ExtendFloat32(list *[]float32, another []float32) []float32

ExtendFloat32 : adds two slice together

func ExtendFloat64

func ExtendFloat64(list *[]float64, another []float64) []float64

ExtendFloat64 : adds two slice together

func ExtendInt

func ExtendInt(list *[]int, another []int) []int

ExtendInt : adds two slice together

func ExtendInt32

func ExtendInt32(list *[]int32, another []int32) []int32

ExtendInt32 : adds two slice together

func ExtendInt64

func ExtendInt64(list *[]int64, another []int64) []int64

ExtendInt64 : adds two slice together

func ExtendString

func ExtendString(list *[]string, another []string) []string

ExtendString : adds two slice together

func GCFFloat32 added in v1.1.5

func GCFFloat32(list *[]float32) (gcf float32, err error)

GCFFloat32 : returns greatest common factor of slice

func GCFFloat64 added in v1.1.5

func GCFFloat64(list *[]float64) (gcf float64, err error)

GCFFloat64 : helper function for gcf

func GCFInt added in v1.1.5

func GCFInt(list *[]int) (gcf int, err error)

GCFInt : returns gcf of list

func GCFInt32 added in v1.1.5

func GCFInt32(list *[]int32) (gcf int32, err error)

GCFInt32 : returns greatest common factor of slice

func GCFInt64 added in v1.1.5

func GCFInt64(list *[]int64) (gcf int64, err error)

GCFInt64 : returns greatest common factor of slice

func IndexOfFloat32

func IndexOfFloat32(array *[]float32, element float32) int

IndexOfFloat32 : returns index of element. returns -1 if element dont exist

func IndexOfFloat64

func IndexOfFloat64(array *[]float64, element float64) int

IndexOfFloat64 : returns index of element. returns -1 if element dont exist

func IndexOfInt

func IndexOfInt(array *[]int, element int) int

IndexOfInt : returns index of element. returns -1 if element dont exist

func IndexOfInt32

func IndexOfInt32(array *[]int32, element int32) int

IndexOfInt32 : returns index of element. returns -1 if element dont exist

func IndexOfInt64

func IndexOfInt64(list *[]int64, element int64) int

IndexOfInt64 : returns index of element. returns -1 if element dont exist

func IndexOfString

func IndexOfString(array *[]string, element string) int

IndexOfString : returns index of element. returns -1 if element dont exist

func InsertFloat32

func InsertFloat32(list *[]float32, element float32, index int) *[]float32

InsertFloat32 : insert an element in a given position

func InsertFloat64

func InsertFloat64(list *[]float64, element float64, index int) *[]float64

InsertFloat64 : insert an element in a given position

func InsertInt

func InsertInt(list *[]int, element int, index int) *[]int

InsertInt : insert an element in a given position

func InsertInt32

func InsertInt32(list *[]int32, element int32, index int) *[]int32

InsertInt32 : insert an element in a given position

func InsertInt64

func InsertInt64(list *[]int64, element int64, index int) *[]int64

InsertInt64 : insert an element in a given position

func InsertString

func InsertString(list *[]string, element string, index int) *[]string

InsertString : insert an element in a given position

func LCMFloat32 added in v1.1.5

func LCMFloat32(list *[]float32) (lcm float32, err error)

LCMFloat32 : returns lowest common multiple of slice

func LCMFloat64 added in v1.1.5

func LCMFloat64(list *[]float64) (lcm float64, err error)

LCMFloat64 : returns lowest common multiple of slice

func LCMInt added in v1.1.5

func LCMInt(list *[]int) (lcm int, err error)

LCMInt : returns lowest common multiple of slice

func LCMInt32 added in v1.1.5

func LCMInt32(list *[]int32) (lcm int32, err error)

LCMInt32 : returns lowest common multiple of slice

func LCMInt64 added in v1.1.5

func LCMInt64(list *[]int64) (lcm int64, err error)

LCMInt64 : returns lowest common multiple of slice

func LastFloat32

func LastFloat32(list []float32) (float32, error)

LastFloat32 : return last element in slice

func LastFloat64

func LastFloat64(list []float64) (float64, error)

LastFloat64 : return last element in slice

func LastInt

func LastInt(array []int) (int, error)

LastInt : return last element in slice

func LastInt32

func LastInt32(list []int32) (int32, error)

LastInt32 : return last element in slice

func LastInt64

func LastInt64(list []int64) (int64, error)

LastInt64 : return last element in slice

func LastString

func LastString(array []string) (string, error)

LastString : return last element in slice

func ListDivideFloat32 added in v1.4.0

func ListDivideFloat32(list []float32, other []float32) (product []float32)

ListDivideFloat32 divide the contents of two lists

func ListDivideFloat64 added in v1.4.0

func ListDivideFloat64(list []float64, other []float64) (product []float64)

ListDivideFloat64 divide the contents of two lists

func ListDivideInt added in v1.4.0

func ListDivideInt(list []int, other []int) (product []int)

ListDivideInt divide the contents of two lists

func ListDivideInt32 added in v1.4.0

func ListDivideInt32(list []int32, other []int32) (product []int32)

ListDivideInt32 divide the contents of two lists

func ListDivideInt64 added in v1.4.0

func ListDivideInt64(list []int64, other []int64) (product []int64)

ListDivideInt64 divide the contents of two lists

func ListDivideNoFloat32 added in v1.4.0

func ListDivideNoFloat32(list []float32, no float32) (product []float32)

ListDivideNoFloat32 divide a given number with all elements in list

func ListDivideNoFloat64 added in v1.4.0

func ListDivideNoFloat64(list []float64, no float64) (product []float64)

ListDivideNoFloat64 divide a given number with all elements in list

func ListDivideNoInt added in v1.4.0

func ListDivideNoInt(list []int, no int) (product []int)

ListDivideNoInt divide a given number with all elements in list

func ListDivideNoInt32 added in v1.4.0

func ListDivideNoInt32(list []int32, no int32) (product []int32)

ListDivideNoInt32 divide a given number with all elements in list

func ListDivideNoInt64 added in v1.4.0

func ListDivideNoInt64(list []int64, no int64) (product []int64)

ListDivideNoInt64 divide a given number with all elements in list

func ListMultiplyFloat32 added in v1.4.0

func ListMultiplyFloat32(list []float32, other []float32) (product []float32)

ListMultiplyFloat32 multiply contents of two lists

func ListMultiplyFloat64 added in v1.4.0

func ListMultiplyFloat64(list []float64, other []float64) (product []float64)

ListMultiplyFloat64 multiply contents of two lists

func ListMultiplyInt added in v1.4.0

func ListMultiplyInt(list []int, other []int) (product []int)

ListMultiplyInt multiply contents of two lists

func ListMultiplyInt32 added in v1.4.0

func ListMultiplyInt32(list []int32, other []int32) (product []int32)

ListMultiplyInt32 multiply contents of two lists

func ListMultiplyInt64 added in v1.4.0

func ListMultiplyInt64(list []int64, other []int64) (product []int64)

ListMultiplyInt64 multiply contents of two lists

func ListMultiplyNoFloat32 added in v1.4.0

func ListMultiplyNoFloat32(list []float32, no float32) (product []float32)

ListMultiplyNoFloat32 multiply a given number with all elements in list

func ListMultiplyNoFloat64 added in v1.4.0

func ListMultiplyNoFloat64(list []float64, no float64) (product []float64)

ListMultiplyNoFloat64 multiply a given number with all elements in list

func ListMultiplyNoInt added in v1.4.0

func ListMultiplyNoInt(list []int, no int) (product []int)

ListMultiplyNoInt multiply a given number with all elements in list

func ListMultiplyNoInt32 added in v1.4.0

func ListMultiplyNoInt32(list []int32, no int32) (product []int32)

ListMultiplyNoInt32 multiply a given number with all elements in list

func ListMultiplyNoInt64 added in v1.4.0

func ListMultiplyNoInt64(list []int64, no int64) (product []int64)

ListMultiplyNoInt64 multiply a given number with all elements in list

func ListSubtractFloat32 added in v1.4.0

func ListSubtractFloat32(list []float32, other []float32) (sum []float32)

ListSubtractFloat32 subtracts the contents of two lists

func ListSubtractFloat64 added in v1.4.0

func ListSubtractFloat64(list []float64, other []float64) (sum []float64)

ListSubtractFloat64 subtracts the contents of two lists

func ListSubtractInt added in v1.4.0

func ListSubtractInt(list []int, other []int) (sum []int)

ListSubtractInt subtracts the contents of two lists

func ListSubtractInt32 added in v1.4.0

func ListSubtractInt32(list []int32, other []int32) (sum []int32)

ListSubtractInt32 subtracts the contents of two lists

func ListSubtractInt64 added in v1.4.0

func ListSubtractInt64(list []int64, other []int64) (sum []int64)

ListSubtractInt64 subtracts the contents of two lists

func ListSubtractNoFloat32 added in v1.4.0

func ListSubtractNoFloat32(list []float32, no float32) (sum []float32)

ListSubtractNoFloat32 subtracts an element from the contents a list

func ListSubtractNoFloat64 added in v1.4.0

func ListSubtractNoFloat64(list []float64, no float64) (sum []float64)

ListSubtractNoFloat64 subtracts an element from the contents a list

func ListSubtractNoInt added in v1.4.0

func ListSubtractNoInt(list []int, no int) (sum []int)

ListSubtractNoInt subtracts an element from the contents a list

func ListSubtractNoInt32 added in v1.4.0

func ListSubtractNoInt32(list []int32, no int32) (sum []int32)

ListSubtractNoInt32 subtracts an element from the contents a list

func ListSubtractNoInt64 added in v1.4.0

func ListSubtractNoInt64(list []int64, no int64) (sum []int64)

ListSubtractNoInt64 subtracts an element from the contents a list

func ListSumFloat32 added in v1.4.0

func ListSumFloat32(list []float32, other []float32) (sum []float32)

ListSumFloat32 sums contents of two lists

func ListSumFloat64 added in v1.4.0

func ListSumFloat64(list []float64, other []float64) (sum []float64)

ListSumFloat64 sums contents of two lists

func ListSumInt added in v1.4.0

func ListSumInt(list []int, other []int) (sum []int)

ListSumInt sums contents of two lists

func ListSumInt32 added in v1.4.0

func ListSumInt32(list []int32, other []int32) (sum []int32)

ListSumInt32 sums contents of two lists

func ListSumInt64 added in v1.4.0

func ListSumInt64(list []int64, other []int64) (sum []int64)

ListSumInt64 sums contents of two lists

func ListSumNoFloat32 added in v1.4.0

func ListSumNoFloat32(list []float32, no float32) (sum []float32)

ListSumNoFloat32 sums contents of two lists

func ListSumNoFloat64 added in v1.4.0

func ListSumNoFloat64(list []float64, no float64) (sum []float64)

ListSumNoFloat64 sums contents of two lists

func ListSumNoInt added in v1.4.0

func ListSumNoInt(list []int, no int) (sum []int)

ListSumNoInt sums contents of two lists

func ListSumNoInt32 added in v1.4.0

func ListSumNoInt32(list []int32, no int32) (sum []int32)

ListSumNoInt32 sums contents of two lists

func ListSumNoInt64 added in v1.4.0

func ListSumNoInt64(list []int64, no int64) (sum []int64)

ListSumNoInt64 sums contents of two lists

func MaxFloat32 added in v1.1.4

func MaxFloat32(list *[]float32) (max float32)

MaxFloat32 : returns max element in slice

func MaxFloat64 added in v1.1.4

func MaxFloat64(list *[]float64) (max float64)

MaxFloat64 : returns max element in slice

func MaxInt added in v1.1.4

func MaxInt(list *[]int) (max int)

MaxInt : returns max element in slice

func MaxInt32 added in v1.1.4

func MaxInt32(list *[]int32) (max int32)

MaxInt32 : returns max element in slice

func MaxInt64 added in v1.1.4

func MaxInt64(list *[]int64) (max int64)

MaxInt64 : returns max element in slice

func MaxString added in v1.1.4

func MaxString(list *[]string) (max string)

MaxString : returns max element in slice

func MinFloat32 added in v1.1.4

func MinFloat32(list *[]float32) (min float32)

MinFloat32 : returns min element in slice

func MinFloat64 added in v1.1.4

func MinFloat64(list *[]float64) (min float64)

MinFloat64 : returns min element in slice

func MinInt added in v1.1.4

func MinInt(list *[]int) (min int)

MinInt : returns min element in slice

func MinInt32 added in v1.1.4

func MinInt32(list *[]int32) (min int32)

MinInt32 : returns min element in slice

func MinInt64 added in v1.1.4

func MinInt64(list *[]int64) (min int64)

MinInt64 : returns min element in slice

func MinString added in v1.1.4

func MinString(list *[]string) (min string)

MinString : returns min element in slice

func PopFloat32

func PopFloat32(list *[]float32, index int) ([]float32, float32)

PopFloat32 : removes element from slice

func PopFloat64

func PopFloat64(list *[]float64, index int) ([]float64, float64)

PopFloat64 : removes element from slice

func PopInt

func PopInt(list *[]int, index int) ([]int, int)

PopInt : removes element from slice

func PopInt32

func PopInt32(list *[]int32, index int) ([]int32, int32)

PopInt32 : removes element from slice

func PopInt64

func PopInt64(list *[]int64, index int) ([]int64, int64)

PopInt64 : removes element from slice

func PopString

func PopString(list *[]string, index int) ([]string, string)

PopString : removes element from slice

func RemoveFloat32

func RemoveFloat32(list *[]float32, element float32) (*[]float32, error)

RemoveFloat32 : removes given element from slice

func RemoveFloat64

func RemoveFloat64(list *[]float64, element float64) (*[]float64, error)

RemoveFloat64 : removes given element from slice

func RemoveInt

func RemoveInt(list *[]int, element int) (*[]int, error)

RemoveInt : removes given element from slice

func RemoveInt32

func RemoveInt32(list *[]int32, element int32) (*[]int32, error)

RemoveInt32 : removes given element from slice

func RemoveInt64

func RemoveInt64(list *[]int64, element int64) (*[]int64, error)

RemoveInt64 : removes given element from slice

func RemoveString

func RemoveString(list *[]string, element string) (*[]string, error)

RemoveString : removes given element from slice

func ReverseFloat32

func ReverseFloat32(list *[]float32) *[]float32

ReverseFloat32 : reverse the positions of elements in slice

func ReverseFloat64

func ReverseFloat64(list *[]float64) *[]float64

ReverseFloat64 : reverse the positions of elements in slice

func ReverseInt

func ReverseInt(list *[]int) *[]int

ReverseInt : reverse the positions of elements in slice

func ReverseInt32

func ReverseInt32(list *[]int32) *[]int32

ReverseInt32 : reverse the positions of elements in slice

func ReverseInt64

func ReverseInt64(list *[]int64) *[]int64

ReverseInt64 : reverse the positions of elements in slice

func ReverseString

func ReverseString(list *[]string) *[]string

ReverseString : reverse the positions of elements in slice

func RoundFloat64 added in v1.1.5

func RoundFloat64(num float64, precision int) float64

RoundFloat64 : rounds float with a precision

func SetFloat32 added in v1.1.6

func SetFloat32(list []float32) (set []float32)

SetFloat32 : returns a set of slice i.e removes duplicates

func SetFloat64 added in v1.1.6

func SetFloat64(list []float64) (set []float64)

SetFloat64 : returns a set of slice i.e removes duplicates

func SetInt added in v1.1.6

func SetInt(list []int) (set []int)

SetInt : returns a set of slice i.e removes duplicates

func SetInt32 added in v1.1.6

func SetInt32(list []int32) (set []int32)

SetInt32 : returns a set of slice i.e removes duplicates

func SetInt64 added in v1.1.6

func SetInt64(list []int64) (set []int64)

SetInt64 : returns a set of slice i.e removes duplicates

func SetString added in v1.1.6

func SetString(list []string) (set []string)

SetString returns a set of slice i.e removes duplicates

func SortFloat32

func SortFloat32(list *[]float32, reverse bool) *[]float32

SortFloat32 : sorts slice

func SortFloat64

func SortFloat64(list *[]float64, reverse bool) *[]float64

SortFloat64 : sorts slice

func SortInt

func SortInt(list *[]int, reverse bool) *[]int

SortInt : sorts slice

func SortInt32

func SortInt32(list *[]int32, reverse bool) *[]int32

SortInt32 : sorts slice

func SortInt64

func SortInt64(list *[]int64, reverse bool) *[]int64

SortInt64 : sorts slice

func SortString

func SortString(list *[]string, reverse bool) *[]string

SortString : sorts slice

func SumFloat32 added in v1.1.3

func SumFloat32(list *[]float32) (sum float32)

SumFloat32 : sum of elements in slice

func SumFloat64 added in v1.1.3

func SumFloat64(list *[]float64) (sum float64)

SumFloat64 : sum of elements in slice

func SumInt added in v1.1.3

func SumInt(list *[]int) (sum int)

SumInt : sum of elements in slice

func SumInt32 added in v1.1.3

func SumInt32(list *[]int32) (sum int32)

SumInt32 : sum of elements in slice

func SumInt64 added in v1.1.3

func SumInt64(list *[]int64) (sum int64)

SumInt64 : sum of elements in slice

func SumString added in v1.1.3

func SumString(list *[]string) (sum string)

SumString : joins elements in slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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