func (vex VectorExpr) Eval(env core.Env) (core.Any, error) {
	cnt, err := vex.Vector.Count()
	if err != nil || cnt == 0 {
		return vex.Vector, err
	}
	for i := 0; i < cnt; i++ {
		any, err := vex.Vector.EntryAt(i)
		if err != nil {
			return nil, err
		}
		other, err := core.Eval(env, vex.Analyzer, any)
		if err != nil {
			return nil, err
		}
		if any == other {
			continue
		}
		if vex.Vector, err = vex.Vector.Assoc(i, other); err != nil {
			return nil, err
		}
	}
	return vex.Vector, nil
}
Eval returns a new vector whose contents are the evaluated values
of the objects contained by the evaluated vector. Elements are evaluated left to right.
package builtin
import (
	"errors"
	"fmt"
	"reflect"
	"github.com/spy16/slurp/core"
)
var (
	_ core.Expr = (*DoExpr)(nil)
	_ core.Expr = (*IfExpr)(nil)
	_ core.Expr = (*DefExpr)(nil)
	_ core.Expr = (*QuoteExpr)(nil)
	_ core.Expr = (*ConstExpr)(nil)
	_ core.Expr = (*InvokeExpr)(nil)
	_ core.Expr = (*ResolveExpr)(nil)
)
type ConstExpr struct{ Const core.Any }
func (ce ConstExpr) Eval(_ core.Env) (core.Any, error) { return ce.Const, nil }
type QuoteExpr struct{ Form core.Any }
func (qe QuoteExpr) Eval(_ core.Env) (core.Any, error) { return qe.Form, nil }
type DefExpr struct {
	Name  string
	Value core.Expr
}
func (de DefExpr) Eval(env core.Env) (core.Any, error) {
	var val core.Any
	var err error
	if de.Value != nil {
		val, err = de.Value.Eval(env)
		if err != nil {
			return nil, err
		}
	} else {
		val = Nil{}
	}
	if err := core.Root(env).Bind(de.Name, val); err != nil {
		return nil, err
	}
	return Symbol(de.Name), nil
}
type LetExpr struct {
	Names  []string
	Values []core.Expr
	Exprs  DoExpr
}
func (le LetExpr) Eval(env core.Env) (_ core.Any, err error) {
	bs := make(map[string]core.Any, len(le.Names))
	for i, symbol := range le.Names {
		if bs[symbol], err = le.Values[i].Eval(env); err != nil {
			return
		}
	}
	return le.Exprs.Eval(env.Child("<let>", bs))
}
type IfExpr struct{ Test, Then, Else core.Expr }
func (ife IfExpr) Eval(env core.Env) (core.Any, error) {
	target := ife.Else
	if ife.Test != nil {
		test, err := ife.Test.Eval(env)
		if err != nil {
			return nil, err
		}
		if IsTruthy(test) {
			target = ife.Then
		}
	}
	if target == nil {
		return Nil{}, nil
	}
	return target.Eval(env)
}
type DoExpr []core.Expr
func (de DoExpr) Eval(env core.Env) (core.Any, error) {
	var res core.Any
	var err error
	for _, expr := range de {
		res, err = expr.Eval(env)
		if err != nil {
			return nil, err
		}
	}
	if res == nil {
		return Nil{}, nil
	}
	return res, nil
}
type ResolveExpr struct{ Symbol Symbol }
func (re ResolveExpr) Eval(env core.Env) (core.Any, error) {
	var v core.Any
	var err error
	for env != nil {
		v, err = env.Resolve(string(re.Symbol))
		if errors.Is(err, core.ErrNotFound) {
			env = env.Parent()
			continue
		}
		break
	}
	return v, err
}
type GoExpr struct{ Form core.Expr }
func (ge GoExpr) Eval(env core.Env) (core.Any, error) {
	e := env.Child("<go>", nil)
	go func() {
		_, _ = ge.Form.Eval(e)
	}()
	return nil, nil
}
type InvokeExpr struct {
	Name   string
	Target core.Expr
	Args   []core.Expr
}
func (ie InvokeExpr) Eval(env core.Env) (core.Any, error) {
	val, err := ie.Target.Eval(env)
	if err != nil {
		return nil, err
	} else if val == nil {
		return nil, core.Error{
			Cause:   core.ErrNotInvokable,
			Message: "'nil'",
		}
	}
	fn, ok := val.(core.Invokable)
	if !ok {
		return nil, core.Error{
			Cause:   core.ErrNotInvokable,
			Message: fmt.Sprintf("value of type '%s' is not invokable", reflect.TypeOf(val)),
		}
	}
	args := make([]core.Any, len(ie.Args))
	for i, ae := range ie.Args {
		if args[i], err = ae.Eval(env); err != nil {
			return nil, err
		}
	}
	return fn.Invoke(args...)
}
type VectorExpr struct {
	Analyzer core.Analyzer
	Vector   core.Vector
}