aboutsummaryrefslogtreecommitdiff
path: root/ruby/types.rb
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-13 14:37:56 -0500
committerJoel Martin <github@martintribe.org>2014-04-13 14:37:56 -0500
commit3a56f91a12ccad642227178c76f8d76cc42f81ee (patch)
tree8ce730b6f4f8cb254dcf8e8f279a57868ae38020 /ruby/types.rb
parent393c1c447fbc61a6c84b7b003f98f6bd6a4add41 (diff)
downloadmal-3a56f91a12ccad642227178c76f8d76cc42f81ee.tar.gz
mal-3a56f91a12ccad642227178c76f8d76cc42f81ee.zip
Ruby: add stepA_more and rest of core functions.
Diffstat (limited to 'ruby/types.rb')
-rw-r--r--ruby/types.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/ruby/types.rb b/ruby/types.rb
index c19fda4..b16e391 100644
--- a/ruby/types.rb
+++ b/ruby/types.rb
@@ -1,9 +1,30 @@
require "env"
+class MalException < StandardError
+ attr_reader :data
+ def initialize(data)
+ @data = data
+ end
+end
+
class List < Array
+ attr_accessor :meta
+ def conj(xs)
+ xs.each{|x| self.unshift(x)}
+ return self
+ end
end
class Vector < Array
+ attr_accessor :meta
+ def conj(xs)
+ self.push(*xs)
+ return self
+ end
+end
+
+class Hash # re-open and add meta
+ attr_accessor :meta
end
def sequential?(obj)
@@ -11,6 +32,7 @@ def sequential?(obj)
end
class Function < Proc
+ attr_accessor :meta
attr_accessor :ast
attr_accessor :env
attr_accessor :params
@@ -28,3 +50,11 @@ class Function < Proc
return Env.new(@env, @params, args)
end
end
+
+class Atom
+ attr_accessor :meta
+ attr_accessor :val
+ def initialize(val)
+ @val = val
+ end
+end