From 3a56f91a12ccad642227178c76f8d76cc42f81ee Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sun, 13 Apr 2014 14:37:56 -0500 Subject: Ruby: add stepA_more and rest of core functions. --- ruby/types.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'ruby/types.rb') 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 -- cgit v1.2.3