Exemplo n.º 1
0
 def test_apply(self):
     env = Environment(primitive_procedure_names,
                       primitive_procedure_objects)
     # test compound procedure
     parameters = ["x"]
     body = [1, 2]
     procedure = eval.make_procedure(parameters, body, env)
     self.assertEqual(eval.apply(procedure, [1]), 2)
     # test primitive procedure
     add = env.get_binding('+')
     self.assertEqual(eval.apply(add, [1, 2]), 3)
     # test exception
     procedure = ["!!!!!", ["x"], [1, 2], env]
     with self.assertRaises(ApplyError):
         eval.apply(procedure, [1])
Exemplo n.º 2
0
    def schemeCallcc(self, cont, env, args):
        lambdaBody = args[0]

        def c2(val):
            return pogo.bounce(cont, val)

        cont_procedure = expressions.makeContinuationProcedure(c2)
        return evaluator.apply(lambdaBody, pair.list(cont_procedure), env, cont)
Exemplo n.º 3
0
    def schemeCallcc(self, cont, env, args):
        lambdaBody = args[0]

        def c2(val):
            return pogo.bounce(cont, val)

        cont_procedure = expressions.makeContinuationProcedure(c2)
        return evaluator.apply(lambdaBody, pair.list(cont_procedure), env,
                               cont)
Exemplo n.º 4
0
 def schemeApply(self, cont, env, args):
     return evaluator.apply(args[0], args[1], env, cont)
Exemplo n.º 5
0
 def schemeApply(self, cont, env, args):
     return evaluator.apply(args[0], args[1], env, cont)