Пример #1
0
  @BIF
  public static ESeq reverse(ESeq front, ESeq res) {
    while (!front.isNil()) {
      res = res.cons(front.head());
      front = front.tail();
    }

    return res;
  }
Пример #2
0
  @BIF
  public static ESeq map(EProc proc, EObject f, EObject s) throws Pausable {
    EFun fun = f.testFunction2(1);
    ESeq seq = s.testSeq();
    if (fun == null || seq == null) throw ERT.badarg(f, s);

    EObject[] arg = new EObject[1];

    ESeq rev = ERT.NIL;
    for (; !seq.isNil(); seq = seq.tail()) {
      arg[0] = seq.head();
      rev = rev.cons(fun.invoke(proc, arg));
    }

    return reverse(rev, ERT.NIL);
  }