diff options
| author | Joel Martin <github@martintribe.org> | 2014-12-18 20:33:49 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:50 -0600 |
| commit | b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch) | |
| tree | f4d977ed220e9a3f665cfbf4f68770a81e4c2095 /go/src/types | |
| parent | aaba249304b184e12e2445ab22d66df1f39a51a5 (diff) | |
| download | mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip | |
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'go/src/types')
| -rw-r--r-- | go/src/types/types.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/go/src/types/types.go b/go/src/types/types.go index 613bfb5..54e4176 100644 --- a/go/src/types/types.go +++ b/go/src/types/types.go @@ -4,6 +4,7 @@ import ( "reflect" "errors" "fmt" + "strings" ) // Errors/Exceptions @@ -21,10 +22,9 @@ type MalType interface { } type EnvType interface { - //Find(key string) *EnvType - Find(key string) EnvType - Set(key string, value MalType) MalType - Get(key string) (MalType, error) + Find(key Symbol) EnvType + Set(key Symbol, value MalType) MalType + Get(key Symbol) (MalType, error) } // Scalars @@ -57,6 +57,20 @@ func Symbol_Q(obj MalType) bool { } +// Keywords +func NewKeyword(s string) (MalType, error) { + return "\u029e" + s, nil; +} + +func Keyword_Q(obj MalType) bool { + if obj == nil { return false } + switch s := obj.(type) { + case string: return strings.HasPrefix(s, "\u029e") + default: return false + } +} + + // Strings func String_Q(obj MalType) bool { if obj == nil { return false } |
