function

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const MaximumNumberOfParamsLimit = 255

MaximumNumberOfParamsLimit for the function

Variables

View Source
var (
	AbsFunction = Function{
		Name:          "abs",
		Arity:         1,
		FunctionImpl:  absImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the absolute value of a number.\n Returns a number.",
	}
	CbrtFunction = Function{
		Name:          "cbrt",
		Arity:         1,
		FunctionImpl:  cbrtImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the cube root of a number.\n Returns a number.",
	}
	CeilFunction = Function{
		Name:          "ceil",
		Arity:         1,
		FunctionImpl:  ceilImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the smallest integer greater than or equal to a number.\n Returns a number.",
	}
	ExpFunction = Function{
		Name:          "exp",
		Arity:         1,
		FunctionImpl:  expImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns E^x, where x is the argument, and E is Euler's constant (2.718…), the base of the natural logarithm.\n Returns a number.",
	}
	FloorFunction = Function{
		Name:          "floor",
		Arity:         1,
		FunctionImpl:  floorImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the largest integer less than or equal to a number.\n Returns a number.",
	}
	LnFunction = Function{
		Name:          "ln",
		Arity:         1,
		FunctionImpl:  lnImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the natural logarithm of a number.\n Returns a number.",
	}
	Log10Function = Function{
		Name:          "log10",
		Arity:         1,
		FunctionImpl:  log10Impl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the base 10 logarithm of a number.\n Returns a number.",
	}
	Log2Function = Function{
		Name:          "log2",
		Arity:         1,
		FunctionImpl:  log2Impl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the base 2 logarithm of a number.\n Returns a number.",
	}
	MaxFunction = Function{
		Name:          "max",
		Arity:         -1,
		MinArity:      1,
		MaxArity:      MaximumNumberOfParamsLimit,
		FunctionImpl:  maxImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the largest number from a list, where numbers are separated by commas.\n Returns a number",
	}
	MinFunction = Function{
		Name:          "min",
		Arity:         -1,
		MinArity:      1,
		MaxArity:      MaximumNumberOfParamsLimit,
		FunctionImpl:  minImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the smallest number from a list, where numbers are separated by commas.\n Returns a number.",
	}
	PowFunction = Function{
		Name:          "pow",
		Arity:         2,
		FunctionImpl:  powImpl,
		ParamsType:    []uint{datatype.NumberType, datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns base to the exponent power.\n Returns a number.",
	}
	RoundFunction = Function{
		Name:          "round",
		Arity:         1,
		FunctionImpl:  roundImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Rounds a number to the nearest integer.\n Returns a number.",
	}
	SignFunction = Function{
		Name:          "sign",
		Arity:         1,
		FunctionImpl:  signImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the sign of a number, indicating whether it's positive (1), negative (-1) or zero (0).\n Returns a number.",
	}
	SqrtFunction = Function{
		Name:          "sqrt",
		Arity:         1,
		FunctionImpl:  sqrtImpl,
		ParamsType:    []uint{datatype.NumberType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the square root of a number.\n Returns a number.",
	}
	TonumberFunction = Function{
		Name:          "toNumber",
		Arity:         1,
		FunctionImpl:  toNumberImpl,
		ParamsType:    []uint{datatype.StringType},
		ReturnType:    datatype.NumberType,
		Documentation: "Converts a text string to a number.\n Returns a number.",
	}

	ConcantFunction = Function{
		Name:          "concat",
		Arity:         -1,
		MinArity:      1,
		MaxArity:      MaximumNumberOfParamsLimit,
		FunctionImpl:  concatImpl,
		ParamsType:    []uint{datatype.StringType},
		ReturnType:    datatype.StringType,
		Documentation: "Concatenates (combines) text strings.\n Returns a text string.",
	}

	ContainsFunction = Function{
		Name:          "contains",
		Arity:         2,
		FunctionImpl:  containsImpl,
		ParamsType:    []uint{datatype.StringType, datatype.StringType},
		ReturnType:    datatype.BooleanType,
		Documentation: "Tests whether a text string contains another text string.\n Returns a boolean.",
	}

	JoinFunction = Function{
		Name:          "join",
		Arity:         -1,
		MinArity:      2,
		MaxArity:      MaximumNumberOfParamsLimit,
		FunctionImpl:  joinImpl,
		ParamsType:    []uint{datatype.StringType},
		ReturnType:    datatype.StringType,
		Documentation: "Combines text strings, with a specified delimiter.\n Returns a text string.",
	}

	LengthFunction = Function{
		Name:          "length",
		Arity:         1,
		FunctionImpl:  lengthImpl,
		ParamsType:    []uint{datatype.StringType},
		ReturnType:    datatype.NumberType,
		Documentation: "Returns the number of characters in a text string.\n Returns a number.",
	}

	ReplaceFunction = Function{
		Name:          "replace",
		Arity:         4,
		FunctionImpl:  replaceImpl,
		ParamsType:    []uint{datatype.StringType, datatype.StringType, datatype.StringType, datatype.NumberType},
		ReturnType:    datatype.StringType,
		Documentation: "Replaces the n match within a text string with a specified new text string.\n Returns a text string.",
	}
	ReplaceAllFunction = Function{
		Name:          "replaceAll",
		Arity:         3,
		FunctionImpl:  replaceAllImpl,
		ParamsType:    []uint{datatype.StringType, datatype.StringType, datatype.StringType},
		ReturnType:    datatype.StringType,
		Documentation: "Replaces all matches within a text string with a specified new text string.\n Returns a text string.",
	}

	SliceFunction = Function{
		Name:          "slice",
		Arity:         3,
		FunctionImpl:  sliceImpl,
		ParamsType:    []uint{datatype.StringType, datatype.NumberType, datatype.NumberType},
		ReturnType:    datatype.StringType,
		Documentation: "Extracts a substring from a text string, given a specified starting point and  end point.\n Returns a text string",
	}
	DefaultFunctions = []Function{
		AbsFunction,
		CbrtFunction,
		CeilFunction,
		ExpFunction,
		FloorFunction,
		LnFunction,
		Log2Function,
		Log10Function,
		MaxFunction,
		MinFunction,
		PowFunction,
		RoundFunction,
		SignFunction,
		SqrtFunction,
		TonumberFunction,
		ConcantFunction,
		ContainsFunction,
		JoinFunction,
		LengthFunction,
		ReplaceFunction,
		ReplaceAllFunction,
		SliceFunction,
	}
)

Functions

View Source
var E, _ = decimal.NewFromString("2.71828182845904523536028747135266249775724709369995957496696763")

E Euler constant

View Source
var PI, _ = decimal.NewFromString("3.14159265358979323846264338327950288419716939937510582097494459")

PI constant

Functions

This section is empty.

Types

type Function

type Function struct {
	Name               string
	Arity              int
	MinArity           uint
	MaxArity           uint
	FunctionImpl       func(args []interface{}) (interface{}, error)
	ParamsType         []uint
	VerifyArgs         func(arguments []interface{}) error
	ReturnType         uint
	Documentation      string
	ArgsDocumentation  string
	ExampleDocumention string
}

Function struct

func (*Function) CheckNumberOfArgs

func (f *Function) CheckNumberOfArgs(arguments []interface{}) error

CheckNumberOfArgs in the function

func (*Function) CheckTypeOfArgs

func (f *Function) CheckTypeOfArgs(arguments []interface{}) bool

CheckTypeOfArgs in the function

Jump to

Keyboard shortcuts

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