- fraction type renamed as FractionType and moved from operator-fraction.go to fraction-type.go - ListType moved from operator-list.go to list-type.go - all test file were renamed adding the "t_" prefix - defined a test template in file t_temple_test.go - new test file t_relational_test.go where relational tests are collected - lists can now compared as set using operators <, <=, >, and >= (IMPORTANT: here = menas same content, not same list)
39 lines
789 B
Go
39 lines
789 B
Go
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// operand-list.go
|
|
package expr
|
|
|
|
// -------- list term
|
|
func newListTermA(args ...*term) *term {
|
|
return newListTerm(0, 0, args)
|
|
}
|
|
|
|
func newListTerm(row, col int, args []*term) *term {
|
|
return &term{
|
|
tk: *NewValueToken(row, col, SymList, "[]", args),
|
|
parent: nil,
|
|
children: nil,
|
|
position: posLeaf,
|
|
priority: priValue,
|
|
evalFunc: evalList,
|
|
}
|
|
}
|
|
|
|
// -------- list func
|
|
func evalList(ctx ExprContext, self *term) (v any, err error) {
|
|
list, _ := self.value().([]*term)
|
|
items := make(ListType, len(list))
|
|
for i, tree := range list {
|
|
var param any
|
|
if param, err = tree.compute(ctx); err != nil {
|
|
break
|
|
}
|
|
items[i] = param
|
|
}
|
|
if err == nil {
|
|
v = &items
|
|
}
|
|
return
|
|
}
|