lib/vm/interpreter.rb in p-lang-0.3.0 vs lib/vm/interpreter.rb in p-lang-0.3.1

- old
+ new

@@ -129,22 +129,31 @@ else lambda[0].form << param end end if next_lambda - lambda |= execute(next_lambda, env).params + lambda << execute(next_lambda, env) + else + lambda << PObject.new(:empty, []) end PObject.new(:lambda, lambda) end def execute_call(lambda, params, env) values = [] params.each do |param| values << execute(param, env) end lambda = execute(lambda, env) - lambda.params.each do |lamb| - return lamb.call(values) if lamb.call?(values) + #lambda.params.each do |lamb| + # return lamb.call(values) if lamb.call?(values) + #end + while lambda.id == :lambda + if lambda.params[0].call?(values) + return lambda.params[0].call(values) + else + lambda = lambda.params[1] + end end raise "CallError" end def execute_let(lhs, rhs, env)