several changes:

1. moved scan/symbol.go to new package sym and adapted all files that reference Symbol type and its values.
2. new type interval defined by begin, end and step values.
3. replaced operator-range.go with operator-interval.go.
4. replaced range operator begin:end with begin..end..step.
5. new implementation of sub-collection extraction based on new interval literal.
This commit is contained in:
2026-07-27 16:01:52 +02:00
parent 07aecfc4e7
commit 8e596d5979
63 changed files with 1125 additions and 755 deletions
+9 -1
View File
@@ -18,7 +18,15 @@ func IsArray(v any) (ok bool) {
return ok
}
func NewArrayA(listAny ...any) (list *ArrayType) {
func NewIntArrayA(listInt ...int) (aRef *ArrayType) {
a := make(ArrayType, len(listInt))
for i, v := range listInt {
a[i] = int64(v)
}
return &a
}
func NewArrayA(listAny ...any) (aRef *ArrayType) {
if listAny == nil {
listAny = []any{}
}
+68
View File
@@ -0,0 +1,68 @@
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// interval.go
package interval
import (
"fmt"
"git.portale-stac.it/go-pkg/expr/kern"
)
const TypeName = "interval"
type IntervalType struct {
begin, end, step int64
}
func NewInterval(begin, end, step int64) *IntervalType {
return &IntervalType{
begin: begin,
end: end,
step: step,
}
}
func (p *IntervalType) Begin() int64 {
return p.begin
}
func (p *IntervalType) End() int64 {
return p.end
}
func (p *IntervalType) Step() int64 {
return p.step
}
func IsInterval(v any) (ok bool) {
_, ok = v.(*IntervalType)
return ok
}
func (p *IntervalType) TypeName() string {
return TypeName
}
func (p *IntervalType) ToString(opt kern.FmtOpt) string {
return fmt.Sprintf("%d..%d..%d", p.begin, p.end, p.step)
}
func (p *IntervalType) String() string {
return p.ToString(0)
}
func (p *IntervalType) ToIntTriple() (b, e, s int) {
b = int(p.begin)
e = int(p.end)
s = int(p.step)
return
}
// func (b *bool) EqualTo(other kern.Equaler) (equal bool) {
// if otherBool, ok := other.(*bool); ok {
// equal = b == otherBool
// }
// return
// }
+74
View File
@@ -19,6 +19,14 @@ func (node *ListNode) Next() *ListNode {
return node.next
}
func (node *ListNode) MoveOn(steps int64) *ListNode {
n := node
for i := int64(0); n != nil && i < steps; i++ {
n = n.Next()
}
return n
}
func (self *ListNode) Data() any {
return self.data
}
@@ -42,6 +50,29 @@ func (ls *LinkedList) Empty() bool {
return ls.count == 0
}
func (ls *LinkedList) PushNodeFront(node *ListNode) *ListNode {
node.next = ls.first
ls.first = node
if ls.last == nil {
ls.last = ls.first
}
ls.count++
return node
}
func (ls *LinkedList) PushNodeBack(node *ListNode) *ListNode {
node.next = nil
if ls.last != nil {
ls.last.next = node
}
ls.last = node
if ls.first == nil {
ls.first = node
}
ls.count++
return node
}
func (ls *LinkedList) PushFront(data any) *ListNode {
ls.first = &ListNode{data, ls.first}
if ls.last == nil {
@@ -231,6 +262,36 @@ func (ls *LinkedList) Sub(start, end int64) (subList *LinkedList) {
return
}
func (ls *LinkedList) SubStep(start, end, step int64) (subList *LinkedList) {
subList = NewLinkedList()
if node, err := ls.NodeAt(start); err == nil {
for i := start; i < end && node != nil; i += step {
subList.PushBack(node.data)
node = node.MoveOn(step)
}
}
return
}
// func (ls *LinkedList) SubStep(start, end, step int64) (subList *LinkedList) {
// subList = NewLinkedList()
// if node, err := ls.NodeAt(start); err == nil {
// forward := step > 0
// if !forward {
// step = -step
// }
// for i := start; i < end && node != nil; i += step {
// if forward {
// subList.PushBack(node.data)
// } else {
// subList.PushFront(node.data)
// }
// node = node.MoveOn(step)
// }
// }
// return
// }
// type TraverseOperator func(index int, elem interface{}, userData interface{}) (err error)
// func (self *LinkedList) Traverse(op TraverseOperator, user_data interface{}) (err error) {
@@ -279,6 +340,19 @@ func (ls *LinkedList) FindNext(eqFunc EqualFunc, startNode *ListNode) (targetNod
return
}
func (ls *LinkedList) Revert() (rls *LinkedList) {
var next *ListNode
node := ls.first
ls.count = 0
ls.first = nil
ls.last = nil
for ; node != nil; node = next {
next = node.next
ls.PushNodeFront(node)
}
return ls
}
// type DataFeeder func(user_data interface{}) interface{}
// type NodeObserver func(node *ListNode, index int, userData interface{})