apply() публичный абстрактный Метод

public abstract apply ( Scheme interpreter, Object args ) : Object
interpreter Scheme
args Object
Результат Object
Пример #1
0
 /** Map proc over a list of lists of args, in the given interpreter.
  * If result is non-null, accumulate the results of each call there
  * and return that at the end.  Otherwise, just return null. **/
 static Pair map(Procedure proc, Object args, Scheme interp, Pair result)
 {
     Pair accum = result;
     if (rest(args) == null)
     {
         args = first(args);
         while (args is Pair)
         {
             Object x = proc.apply(interp, list(first(args)));
             if (accum != null) accum = (Pair) (accum.rest = list(x));
             args = rest(args);
         }
     }
     else
     {
         Procedure car = Procedure.proc(interp.eval("car"));
         Procedure cdr = Procedure.proc(interp.eval("cdr"));
         while  (first(args) is Pair)
         {
             Object x = proc.apply(interp, map(car, list(args), interp, list(null)));
             if (accum != null) accum = (Pair) (accum.rest = list(x));
             args = map(cdr, list(args), interp, list(null));
         }
     }
     return (Pair)rest(result);
 }