Merge pull request #238 from prt2121/pt/haskell-7.10.1
[jackhill/mal.git] / ruby / step9_try.rb
index 74d0f59..828f8c1 100644 (file)
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
 
 # read
 def READ(str)
@@ -72,7 +71,12 @@ def EVAL(ast, env)
 
     # apply list
     ast = macroexpand(ast, env)
-    return ast if not ast.is_a? List
+    if not ast.is_a? List
+        return eval_ast(ast, env)
+    end
+    if ast.empty?
+        return ast
+    end
 
     a0,a1,a2,a3 = ast
     case a0
@@ -123,7 +127,7 @@ def EVAL(ast, env)
         end
     when :"fn*"
         return Function.new(a2, env, a1) {|*args|
-            EVAL(a2, Env.new(env, a1, args))
+            EVAL(a2, Env.new(env, a1, List.new(args)))
         }
     else
         el = eval_ast(ast, env)