コード例 #1
0
ファイル: Cons.java プロジェクト: rritoch/jrelisp-abcl
 public Cons(Cons original) {
   Cons rest = original;
   LispObject result = NIL;
   while (rest.car() != NIL) {
     result = result.push(rest.car());
     if (rest.cdr() == NIL) {
       break;
     }
     rest = (Cons) rest.cdr();
   }
   result = result.nreverse();
   this.car = result.car();
   this.cdr = result.cdr();
   ++count;
 }
コード例 #2
0
ファイル: Cons.java プロジェクト: rritoch/jrelisp-abcl
 @Override
 public final LispObject nreverse() {
   if (cdr.isCons()) {
     Cons cons = (Cons) cdr;
     if (cons.cdr.isCons()) {
       Cons cons1 = cons;
       LispObject list = NIL;
       do {
         Cons temp = (Cons) cons.cdr;
         cons.cdr = list;
         list = cons;
         cons = temp;
       } while (cons.cdr.isCons());
       if (cons.cdr != NIL) return type_error(cons.cdr, Symbol.LIST);
       cdr = list;
       cons1.cdr = cons;
     } else if (cons.cdr != NIL) return type_error(cons.cdr, Symbol.LIST);
     LispObject temp = car;
     car = cons.car;
     cons.car = temp;
   } else if (cdr != NIL) return type_error(cdr, Symbol.LIST);
   return this;
 }