aboutsummaryrefslogtreecommitdiff
path: root/go/src/step4_if_fn_do
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
committerJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
commitf2544a9467ea032aff505b3ced3b4b3510a828fe (patch)
treeaa1984aef01c20b7b093527c28c37bd7d4d803d5 /go/src/step4_if_fn_do
parentf2c9811fd8cbb205fad68952ebc1ba5d310f148d (diff)
downloadmal-f2544a9467ea032aff505b3ced3b4b3510a828fe.tar.gz
mal-f2544a9467ea032aff505b3ced3b4b3510a828fe.zip
go: add metadata and atoms. HashMap dedicated type.
HashMap needs a dedicated type now to be able to store the metadata.
Diffstat (limited to 'go/src/step4_if_fn_do')
-rw-r--r--go/src/step4_if_fn_do/step4_if_fn_do.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/go/src/step4_if_fn_do/step4_if_fn_do.go b/go/src/step4_if_fn_do/step4_if_fn_do.go
index 6a35b85..f63017b 100644
--- a/go/src/step4_if_fn_do/step4_if_fn_do.go
+++ b/go/src/step4_if_fn_do/step4_if_fn_do.go
@@ -32,7 +32,7 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return List{lst}, nil
+ return List{lst,nil}, nil
} else if Vector_Q(ast) {
lst := []MalType{}
for _, a := range ast.(Vector).Val {
@@ -40,11 +40,11 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return Vector{lst}, nil
+ return Vector{lst,nil}, nil
} else if HashMap_Q(ast) {
- m := ast.(map[string]MalType)
- new_hm := map[string]MalType{}
- for k, v := range m {
+ m := ast.(HashMap)
+ new_hm := HashMap{map[string]MalType{},nil}
+ for k, v := range m.Val {
ke, e1 := EVAL(k, env)
if e1 != nil { return nil, e1 }
if _, ok := ke.(string); !ok {
@@ -52,7 +52,7 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
}
kv, e2 := EVAL(v, env)
if e2 != nil { return nil, e2 }
- new_hm[ke.(string)] = kv
+ new_hm.Val[ke.(string)] = kv
}
return new_hm, nil
} else {
@@ -100,7 +100,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) {
}
return EVAL(a2, let_env)
case "do":
- el, e := eval_ast(List{ast.(List).Val[1:]}, env)
+ el, e := eval_ast(List{ast.(List).Val[1:],nil}, env)
if e != nil { return nil, e }
lst := el.(List).Val
if len(lst) == 0 { return nil, nil }
@@ -119,7 +119,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) {
}
case "fn*":
return func(arguments []MalType) (MalType, error) {
- new_env, e := NewEnv(env, a1, List{arguments})
+ new_env, e := NewEnv(env, a1, List{arguments,nil})
if e != nil { return nil, e }
return EVAL(a2, new_env)
}, nil