Documentation
¶
Overview ¶
Package builtin 提供内置函数库
内置函数包括:
- Math: 数学函数(abs, ceil, floor, round, max, min, sqrt, pow)
- String: 字符串函数(concat, length, toUpperCase, toLowerCase, trim, split)
- Array: 数组函数(length, map, filter, reduce, sort, find)
- Object: 对象函数(keys, values, entries)
- Console: 控制台函数(log)
示例:
// 注册所有内置函数
registry := function.NewRegistry()
builtin.RegisterAll(registry)
// 使用内置函数
result, _ := registry.Call("Math.abs", []interface{}{-5.0})
// result = 5.0
Index ¶
- func ArrayFilter(arr []interface{}, predicate func(interface{}) bool) []interface{}
- func ArrayFind(arr []interface{}, predicate func(interface{}) bool) interface{}
- func ArrayMap(arr []interface{}, fn func(interface{}) interface{}) []interface{}
- func ArrayReduce(arr []interface{}, initial interface{}, ...) interface{}
- func RegisterAll(registry function.Registry) error
- func RegisterArray(registry function.Registry) error
- func RegisterConsole(registry function.Registry) error
- func RegisterMath(registry function.Registry) error
- func RegisterObject(registry function.Registry) error
- func RegisterString(registry function.Registry) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayFilter ¶
func ArrayFilter(arr []interface{}, predicate func(interface{}) bool) []interface{}
ArrayFilter 过滤数组元素(需要在求值器中调用)
func ArrayFind ¶
func ArrayFind(arr []interface{}, predicate func(interface{}) bool) interface{}
ArrayFind 查找第一个满足条件的元素(需要在求值器中调用)
func ArrayMap ¶
func ArrayMap(arr []interface{}, fn func(interface{}) interface{}) []interface{}
ArrayMap 对数组每个元素应用函数(需要在求值器中调用)
func ArrayReduce ¶
func ArrayReduce(arr []interface{}, initial interface{}, reducer func(interface{}, interface{}) interface{}) interface{}
ArrayReduce 归约数组(需要在求值器中调用)
func RegisterConsole ¶
RegisterConsole 注册所有控制台函数
func RegisterString ¶
RegisterString 注册所有字符串函数
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.