Пример #1
0
function SCM_if($s, $env)
{
    $cond = $s->car;
    if (Scheme::evaluate($cond, $env) == Symbol::new_instance('#t')) {
        $rule = $s->cdr->car;
    } else {
        $rule = $s->cdr->cdr;
    }
    return SCM_begin($rule, $env);
}
Пример #2
0
 /**
  * 適応
  */
 private static function apply($function, $args, $env)
 {
     if (Object::is_subr($function) || Object::is_expr($function)) {
         $args = self::evlis($args, $env);
     }
     // SUBR
     if (Object::is_subr($function)) {
         return $function->exec($args);
     }
     // FSUBR
     if (Object::is_fsubr($function)) {
         return $function->exec($args, $env);
     }
     // EXPR
     if (Object::is_expr($function)) {
         $new_env = Env::new_expr_instance($args, $function);
         return SCM_begin($function->forms, $new_env);
     }
 }