MCPcopy Index your code
hub / github.com/Shopify/go-lua / reduce

Function reduce

math.go:24–34  ·  view source on GitHub ↗
(f func(float64, float64) float64)

Source from the content-addressed store, hash-verified

22}
23
24func reduce(f func(float64, float64) float64) Function {
25 return func(l *State) int {
26 n := l.Top() // number of arguments
27 v := CheckNumber(l, 1)
28 for i := 2; i <= n; i++ {
29 v = f(v, CheckNumber(l, i))
30 }
31 l.PushNumber(v)
32 return 1
33 }
34}
35
36var mathLibrary = []RegistryFunction{
37 {"abs", mathUnaryOp(math.Abs)},

Callers 1

math.goFile · 0.85

Calls 3

CheckNumberFunction · 0.85
TopMethod · 0.80
PushNumberMethod · 0.80

Tested by

no test coverage detected