'join' operator renamed as 'cat'

This commit is contained in:
2026-05-09 10:34:46 +02:00
parent 5950630cf7
commit 5285b61320
3 changed files with 12 additions and 10 deletions
+6 -6
View File
@@ -1,7 +1,7 @@
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com). // Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved. // All rights reserved.
// operator-join.go // operator-cat.go
package expr package expr
import ( import (
@@ -12,19 +12,19 @@ import (
"git.portale-stac.it/go-pkg/expr/scan" "git.portale-stac.it/go-pkg/expr/scan"
) )
//-------- join term //-------- cat term
func newJoinTerm(tk *scan.Token) (inst *scan.Term) { func newCatTerm(tk *scan.Token) (inst *scan.Term) {
return &scan.Term{ return &scan.Term{
Tk: *tk, Tk: *tk,
Children: make([]*scan.Term, 0, 2), Children: make([]*scan.Term, 0, 2),
Position: scan.PosInfix, Position: scan.PosInfix,
Priority: scan.PriIterOp, Priority: scan.PriIterOp,
EvalFunc: evalJoin, EvalFunc: evalCat,
} }
} }
func evalJoin(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) { func evalCat(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
var leftValue, rightValue any var leftValue, rightValue any
var itLeft, itRight kern.Iterator var itLeft, itRight kern.Iterator
var item any var item any
@@ -69,5 +69,5 @@ func evalJoin(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
// init // init
func init() { func init() {
scan.RegisterTermConstructor(scan.SymKwJoin, newJoinTerm) scan.RegisterTermConstructor(scan.SymKwCat, newCatTerm)
} }
+2
View File
@@ -122,6 +122,7 @@ const (
SymKwMap SymKwMap
SymKwFilter SymKwFilter
SymKwDigest SymKwDigest
SymKwCat
SymKwGroupBy SymKwGroupBy
SymKwJoin SymKwJoin
SymKwNil SymKwNil
@@ -141,6 +142,7 @@ func init() {
"IN": SymKwIn, "IN": SymKwIn,
"INCLUDE": SymKwInclude, "INCLUDE": SymKwInclude,
"MAP": SymKwMap, "MAP": SymKwMap,
"CAT": SymKwCat,
"FILTER": SymKwFilter, "FILTER": SymKwFilter,
"NOT": SymKwNot, "NOT": SymKwNot,
"OR": SymKwOr, "OR": SymKwOr,
+4 -4
View File
@@ -75,11 +75,11 @@ func TestOperatorDigest(t *testing.T) {
runTestSuite(t, section, inputs) runTestSuite(t, section, inputs)
} }
func TestOperatorJoin(t *testing.T) { func TestOperatorCat(t *testing.T) {
section := "Operator-Join" section := "Operator-Cat"
inputs := []inputType{ inputs := []inputType{
/* 1 */ {`["a","b"] join ["x"]`, kern.NewList([]any{"a", "b", "x"}), nil}, /* 1 */ {`["a","b"] cat ["x"]`, kern.NewList([]any{"a", "b", "x"}), nil},
/* 2 */ {`["a","b"] join ["x"-true]`, nil, `[1:21] left operand 'x' [string] and right operand 'true' [bool] are not compatible with operator "-"`}, /* 2 */ {`["a","b"] cat ["x"-true]`, nil, `[1:20] left operand 'x' [string] and right operand 'true' [bool] are not compatible with operator "-"`},
} }
// runTestSuiteSpec(t, section, inputs, 2) // runTestSuiteSpec(t, section, inputs, 2)