Example #1
0
 def _list_of_values(self, expressions, env):
     if procedure.no_operands(expressions):
         return EmptyList
     else:
         return cons(
                 self._eval(procedure.first_operand(expressions), env), 
                 self._list_of_values(procedure.rest_operands(expressions), env))
Example #2
0
    def _eval_and(self, expr, env):
        if procedure.no_operands(procedure.operands(expr)):
            return Boolean(True)

        def inner(expr, env):
            if sequence.is_last_expr(expr):
                return self._eval(sequence.first_expr(expr), env)
            if not self._eval(sequence.first_expr(expr), env):
                return Boolean(False)
            return inner(sequence.rest_exprs(expr), env)

        return inner(sequence.rest_exprs(expr), env)
Example #3
0
    def _eval_or(self, expr, env):
        if procedure.no_operands(procedure.operands(expr)):
            return Boolean(False)

        def inner(expr, env):
            if sequence.is_last_expr(expr):
                return self._eval(sequence.first_expr(expr), env)
            first_value = self._eval(sequence.first_expr(expr), env)
            if first_value:
                return first_value
            return inner(sequence.rest_exprs(expr), env)

        return inner(sequence.rest_exprs(expr), env)