From 4512e9711b5d18e9ef49f2393418da44daf64575 Mon Sep 17 00:00:00 2001 From: Cedric Chee Date: Thu, 2 Apr 2020 03:14:49 +0800 Subject: [PATCH] 4.6 Hello World Add one last built-in function: puts. puts prints the given arguments on new lines to STDOUT. --- evaluator/builtins.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/evaluator/builtins.go b/evaluator/builtins.go index 452b472..14f4d67 100644 --- a/evaluator/builtins.go +++ b/evaluator/builtins.go @@ -1,6 +1,8 @@ package evaluator import ( + "fmt" + "github.com/cedrickchee/hou/object" ) @@ -109,4 +111,12 @@ var builtins = map[string]*object.Builtin{ return &object.Array{Elements: newElements} }, }, + "puts": &object.Builtin{ + Fn: func(args ...object.Object) object.Object { + for _, arg := range args { + fmt.Println(arg.Inspect()) + } + return NULL + }, + }, }