@BIF public static ESeq reverse(ESeq front, ESeq res) { while (!front.isNil()) { res = res.cons(front.head()); front = front.tail(); } return res; }
@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); }