Пример #1
0
 public function map(array $args, Scheme_Env $env)
 {
     $this->requireExactly(2, $args);
     $this->requireList($args[1]);
     list($func, $list) = $args;
     $interp = $env->getInterpreter();
     $result = array();
     foreach ($list->listToArray() as $value) {
         $result[] = $interp->evaluate($env, Scheme_Utils::mkList($func, $value));
     }
     return Scheme_Utils::arrayToList($result);
 }
Пример #2
0
 public function assert_equals(array $args)
 {
     $this->requireExactly(2, $args);
     return new Scheme_TailCall(Scheme_Utils::mkList(new Scheme_Symbol('if'), Scheme_Utils::mkList(new Scheme_Symbol('not'), Scheme_Utils::mkList(new Scheme_Symbol('equal?'), $args[0], $args[1])), Scheme_Utils::mkList(new Scheme_Symbol('error!'), new Scheme_String("Expected " . $args[1]->toString() . " to yield " . $args[0]->toString()))));
 }