Add a "bool" builtin.

This commit is contained in:
Qi Xiao 2016-03-10 20:48:59 +01:00
parent 4c938c7393
commit 5ef87a7e7a

View File

@ -92,6 +92,7 @@ func init() {
&BuiltinFn{"base", wrapFn(base)},
&BuiltinFn{"bool", wrapFn(boolFn)},
&BuiltinFn{"==", eq},
&BuiltinFn{"!=", wrapFn(noteq)},
&BuiltinFn{"deepeq", deepeq},
@ -599,6 +600,11 @@ func base(ec *EvalCtx, b int, nums ...int) {
}
}
func boolFn(ec *EvalCtx, v Value) {
out := ec.ports[1].Chan
out <- Bool(ToBool(v))
}
var ErrNotEqual = errors.New("not equal")
func eq(ec *EvalCtx, args []Value) {