func-math.go/add: now supports the general iterator interface
This commit is contained in:
parent
750c660331
commit
62e16219f7
17
func-math.go
17
func-math.go
@ -23,14 +23,19 @@ func doAdd(ctx ExprContext, name string, it Iterator) (result any, err error) {
|
||||
var v any
|
||||
|
||||
for v, err = it.Next(); err == nil; v, err = it.Next() {
|
||||
if err = checkNumberParamExpected(name, v, it.Index()); err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
if array, ok := v.([]any); ok {
|
||||
if v, err = doAdd(ctx, name, NewFlatArrayIterator(array)); err != nil {
|
||||
if subIter, ok := v.(Iterator); ok {
|
||||
if v, err = doAdd(ctx, name, subIter); err != nil {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if err = checkNumberParamExpected(name, v, it.Index()); err != nil {
|
||||
break
|
||||
}
|
||||
if array, ok := v.([]any); ok {
|
||||
if v, err = doAdd(ctx, name, NewFlatArrayIterator(array)); err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !sumAsFloat && isFloat(v) {
|
||||
|
Loading…
Reference in New Issue
Block a user