Iterators now support generic operation interface based on methods HasOperation() and CallOperation().

Also fixed mul() function that called doAdd() instead of doMul().
This commit is contained in:
2024-04-28 06:45:20 +02:00
parent fc0e1ffaee
commit aa66d07caa
5 changed files with 100 additions and 16 deletions
+8
View File
@@ -4,8 +4,16 @@
// iterator.go
package expr
import "fmt"
type Iterator interface {
Next() (item any, err error) // must return io.EOF after the last item
Current() (item any, err error)
Index() int
HasOperation(name string) bool
CallOperation(name string, args []any) (value any, err error)
}
func errNoOperation(name string) error {
return fmt.Errorf("no %q function defined in the data-source", name)
}