linked-list: added forgotten source files
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
||||
// operand-list.go
|
||||
package expr
|
||||
|
||||
import (
|
||||
"git.portale-stac.it/go-pkg/expr/kern"
|
||||
"git.portale-stac.it/go-pkg/expr/scan"
|
||||
)
|
||||
|
||||
// -------- list term
|
||||
// func newLinkedListTermA(args ...*scan.Term) *scan.Term {
|
||||
// return newLinkedListTerm(0, 0, args)
|
||||
// }
|
||||
|
||||
func newLinkedListTerm(row, col int, args []*scan.Term) *scan.Term {
|
||||
return &scan.Term{
|
||||
Tk: *scan.NewValueToken(row, col, scan.SymLinkedList, "[<>]", args),
|
||||
Parent: nil,
|
||||
Children: nil,
|
||||
Position: scan.PosLeaf,
|
||||
Priority: scan.PriValue,
|
||||
EvalFunc: evalLinkedList,
|
||||
}
|
||||
}
|
||||
|
||||
// -------- list func
|
||||
func evalLinkedList(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
list, _ := opTerm.Value().([]*scan.Term)
|
||||
items := kern.NewLinkedList()
|
||||
for _, tree := range list {
|
||||
var param any
|
||||
if param, err = tree.Compute(ctx); err != nil {
|
||||
break
|
||||
}
|
||||
items.PushBack(param)
|
||||
}
|
||||
if err == nil {
|
||||
v = items
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user