|
|
@ -21,9 +21,12 @@ func (s sexp) String() string {
|
|
|
|
type symbol string
|
|
|
|
type symbol string
|
|
|
|
|
|
|
|
|
|
|
|
var universe = &environment{map[symbol]interface{}{
|
|
|
|
var universe = &environment{map[symbol]interface{}{
|
|
|
|
|
|
|
|
// predefined values
|
|
|
|
"#t": true,
|
|
|
|
"#t": true,
|
|
|
|
"#f": false,
|
|
|
|
"#f": false,
|
|
|
|
"null": nil,
|
|
|
|
"null": nil,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// builtin functions
|
|
|
|
"+": builtin(addition),
|
|
|
|
"+": builtin(addition),
|
|
|
|
"-": builtin(subtraction),
|
|
|
|
"-": builtin(subtraction),
|
|
|
|
"*": builtin(multiplication),
|
|
|
|
"*": builtin(multiplication),
|
|
|
@ -33,6 +36,9 @@ var universe = &environment{map[symbol]interface{}{
|
|
|
|
"list?": builtin(islist),
|
|
|
|
"list?": builtin(islist),
|
|
|
|
"not": builtin(not),
|
|
|
|
"not": builtin(not),
|
|
|
|
"null?": builtin(isnull),
|
|
|
|
"null?": builtin(isnull),
|
|
|
|
|
|
|
|
"symbol?": builtin(issymbol),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// special forms
|
|
|
|
"begin": special(begin),
|
|
|
|
"begin": special(begin),
|
|
|
|
"define": special(define),
|
|
|
|
"define": special(define),
|
|
|
|
"if": special(_if),
|
|
|
|
"if": special(_if),
|
|
|
|