iter-ops raised above assign; 'cat' operator returns an iterator; $$ operator supports iterators producing a list of items

This commit is contained in:
2026-05-09 12:15:59 +02:00
parent 5285b61320
commit e5a61b5638
6 changed files with 159 additions and 10 deletions
+43
View File
@@ -7,6 +7,7 @@ package kern
import (
// "errors"
"fmt"
"slices"
)
// Operator names
@@ -50,3 +51,45 @@ func IsIterator(v any) (ok bool) {
_, ok = v.(Iterator)
return
}
type IteratorBase struct {
ItemIndex int64
ItemCount int64
current any
}
func (it *IteratorBase) Current() (item any, err error) {
return it.current, nil
}
func (it *IteratorBase) Index() int64 {
return it.ItemIndex
}
func (it *IteratorBase) Count() int64 {
return it.ItemCount
}
func (it *IteratorBase) HasOperation(name string) bool {
return slices.Contains([]string{NextName, IndexName, CountName, CurrentName}, name)
}
func (it *IteratorBase) Clean() (err error) {
return
}
func (it *IteratorBase) Reset() (err error) {
it.ItemIndex = -1
it.ItemCount = 0
it.current = nil
return
}
func (it *IteratorBase) Increment() {
it.ItemIndex++
it.ItemCount++
}
func (it *IteratorBase) SetCurrent(v any) {
it.current = v
}