commit f892c5c3d8e34786c0396e3ff7c99d771e2b2908
parent 0632ef9289a8bbcbb98af5c0f1f3c0997eecf040
Author: bsandro <email@bsandro.tech>
Date: Fri, 1 Jul 2022 00:04:28 +0300
puts() builtin function
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/eval/builtins.go b/eval/builtins.go
@@ -1,6 +1,9 @@
package eval
-import "interp/object"
+import (
+ "fmt"
+ "interp/object"
+)
var builtins = map[string]*object.Builtin{
"len": &object.Builtin{
@@ -115,4 +118,12 @@ var builtins = map[string]*object.Builtin{
}
},
},
+ "puts": &object.Builtin{
+ Fn: func(args ...object.Object) object.Object {
+ for _, arg := range args {
+ fmt.Println(arg.Inspect())
+ }
+ return NULL
+ },
+ },
}