Skip to content

Commit

Permalink
4.6 Hello World
Browse files Browse the repository at this point in the history
Add one last built-in function: puts.
puts prints the given arguments on new lines to STDOUT.
  • Loading branch information
cedrickchee committed Apr 1, 2020
1 parent 3386b53 commit 4512e97
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions evaluator/builtins.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package evaluator

import (
"fmt"

"github.com/cedrickchee/hou/object"
)

Expand Down Expand Up @@ -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
},
},
}

0 comments on commit 4512e97

Please sign in to comment.