operand-map.go: to be removed

This commit is contained in:
Celestino Amoroso 2024-05-18 08:54:18 +02:00
parent c39970fa7e
commit 263e419d9a

34
operand-map.go Normal file
View File

@ -0,0 +1,34 @@
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// operand-map.go
package expr
// -------- map term
func newMapTerm(args map[any]*term) *term {
return &term{
tk: *NewValueToken(0, 0, SymDict, "{}", args),
parent: nil,
children: nil,
position: posLeaf,
priority: priValue,
evalFunc: evalMap,
}
}
// -------- map func
func evalMap(ctx ExprContext, self *term) (v any, err error) {
dict, _ := self.value().(map[any]*term)
items := make(map[any]any, len(dict))
for key, tree := range dict {
var param any
if param, err = tree.compute(ctx); err != nil {
break
}
items[key] = param
}
if err == nil {
v = items
}
return
}