/
function.go
50 lines (45 loc) · 913 Bytes
/
function.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package function
import (
"strings"
"github.com/anywhereQL/anywhereQL/common/value"
)
type CallFunction func([]value.Value) (value.Value, error)
var funcs = map[string]CallFunction{
// Math funcs
"abs": Abs,
"sign": Sign,
"sgn": Sign,
"floor": Floor,
"ceil": Ceil,
"ceiling": Ceil,
"round": Round,
"trunc": Trunc,
"truncate": Trunc,
"pow": Pow,
"power": Pow,
"sqrt": Sqrt,
"exp": Exp,
"ln": Ln,
"log10": Log10,
"sin": Sin,
"cos": Cos,
"cosh": Cosh,
"tan": Tan,
"acos": Acos,
"asin": Asin,
"atan": Atan,
"atan2": Atan2,
"cot": Cot,
"degrees": Degrees,
"radians": Radians,
"pi": Pi,
"rand": Rand,
"greatest": Greatest,
"least": Least,
}
func LookupFunction(name string) CallFunction {
if f, exists := funcs[strings.ToLower(name)]; exists {
return f
}
return nil
}