implement List right quick
This commit is contained in:
parent
2433e4a175
commit
f751924b26
@ -52,6 +52,11 @@ func (bctx BuildCtx) buildExprTill(e Expr, fn func(e Expr) bool) Expr {
|
||||
ea[i] = bctx.buildExprTill(ea[i], fn)
|
||||
}
|
||||
return ea
|
||||
case List:
|
||||
for i := range ea {
|
||||
ea[i] = bctx.buildExprTill(ea[i], fn)
|
||||
}
|
||||
return ea
|
||||
default:
|
||||
panicf("type %T can't express a value", ea)
|
||||
}
|
||||
|
20
expr/expr.go
20
expr/expr.go
@ -139,6 +139,26 @@ func (tup Tuple) equal(e equaler) bool {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// List represents an ordered set of Exprs, all of the same type. A List's size
|
||||
// does not affect its type signature, unlike a Tuple
|
||||
type List []Expr
|
||||
|
||||
// NewList returns a List around the given list of Exprs
|
||||
func NewList(ee ...Expr) List {
|
||||
return List(ee)
|
||||
}
|
||||
|
||||
func (l List) String() string {
|
||||
return "[" + exprsJoin(l) + "]"
|
||||
}
|
||||
|
||||
func (l List) equal(e equaler) bool {
|
||||
ll, ok := e.(List)
|
||||
return ok && exprsEqual(l, ll)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Statement represents an actual action which will be taken. The input value is
|
||||
// used as the input to the pipe, and the output of the pipe is the output of
|
||||
// the statement
|
||||
|
Loading…
Reference in New Issue
Block a user