lib/lisp.rb in lisp-1.0.6 vs lib/lisp.rb in lisp-1.1.0

- old
+ new

@@ -50,9 +50,15 @@ lambda { |*args| execute(exp, scope.merge(Hash[params.zip(args)])) } when :if _, test, conseq, alt = exp exp = execute(test, scope) ? conseq : alt execute(exp, scope) + when :set! + _, var, exp = exp + if scope.has_key?(var) then scope[var] = execute(exp, scope) else raise "#{var} is undefined" end + when :begin + _, *exp = exp + exp.map { |exp| execute(exp) }.last else func, *args = exp.map { |exp| execute(exp, scope) } func.call(*args) end end