Changeset 4726


Ignore:
Timestamp:
11/14/03 00:53:57 (18 years ago)
Author:
piso
Message:

nreverse()

Location:
trunk/j/src/org/armedbear/lisp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/AbstractVector.java

    r3929 r4726  
    167167    public abstract LispObject reverse() throws ConditionThrowable;
    168168
    169     public void nreverse() throws ConditionThrowable
     169    public LispObject nreverse() throws ConditionThrowable
    170170    {
    171171        int i = 0;
     
    178178            --j;
    179179        }
     180        return this;
    180181    }
    181182}
  • trunk/j/src/org/armedbear/lisp/Cons.java

    r4178 r4726  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Cons.java,v 1.30 2003-10-03 00:21:52 piso Exp $
     5 * $Id: Cons.java,v 1.31 2003-11-14 00:53:06 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    188188    }
    189189
     190    public final LispObject nreverse() throws ConditionThrowable
     191    {
     192        // Following code is from CLISP.
     193        LispObject list3 = cdr;
     194        if (list3 instanceof Cons) {
     195            if (list3.cdr() instanceof Cons) {
     196                LispObject list1 = list3;
     197                LispObject list2 = NIL;
     198                do {
     199                    LispObject h = list3.cdr();
     200                    list3.setCdr(list2);
     201                    list2 = list3;
     202                    list3 = h;
     203                } while (list3.cdr() instanceof Cons);
     204                cdr = list2;
     205                list1.setCdr(list3);
     206            }
     207            LispObject h = this.car();
     208            car = list3.car();
     209            list3.setCar(h);
     210        }
     211        return this;
     212    }
     213
    190214    public final boolean listp()
    191215    {
  • trunk/j/src/org/armedbear/lisp/LispObject.java

    r4725 r4726  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispObject.java,v 1.63 2003-11-14 00:22:52 piso Exp $
     5 * $Id: LispObject.java,v 1.64 2003-11-14 00:46:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    290290    }
    291291
    292     public void nreverse() throws ConditionThrowable
     292    public LispObject nreverse() throws ConditionThrowable
    293293    {
    294294        throw new ConditionThrowable(new TypeError(this, "sequence"));
  • trunk/j/src/org/armedbear/lisp/LispString.java

    r4575 r4726  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispString.java,v 1.63 2003-10-30 08:17:14 asimon Exp $
     5 * $Id: LispString.java,v 1.64 2003-11-14 00:53:57 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    185185    }
    186186
    187     public void nreverse() throws ConditionThrowable
     187    public LispObject nreverse() throws ConditionThrowable
    188188    {
    189189        int i = 0;
     
    196196            --j;
    197197        }
     198        return this;
    198199    }
    199200
  • trunk/j/src/org/armedbear/lisp/Nil.java

    r4607 r4726  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Nil.java,v 1.25 2003-11-02 14:07:30 piso Exp $
     5 * $Id: Nil.java,v 1.26 2003-11-14 00:47:23 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    6767    public LispObject car()
    6868    {
    69         return NIL;
     69        return this;
    7070    }
    7171
    7272    public LispObject cdr()
    7373    {
    74         return NIL;
     74        return this;
    7575    }
    7676
    7777    public final LispObject cadr()
    7878    {
    79         return NIL;
     79        return this;
    8080    }
    8181
    8282    public final LispObject cddr()
    8383    {
    84         return NIL;
     84        return this;
    8585    }
    8686
     
    9393    {
    9494        throw new ConditionThrowable(new TypeError("ELT: invalid index " + index + " for " + this));
     95    }
     96
     97    public LispObject nreverse()
     98    {
     99        return this;
    95100    }
    96101
     
    127132    public LispObject remove(LispObject item) throws ConditionThrowable
    128133    {
    129         return NIL;
     134        return this;
    130135    }
    131136
  • trunk/j/src/org/armedbear/lisp/Vector.java

    r4441 r4726  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Vector.java,v 1.27 2003-10-17 19:37:13 piso Exp $
     5 * $Id: Vector.java,v 1.28 2003-11-14 00:52:09 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    200200    }
    201201
    202     public void nreverse() throws ConditionThrowable
     202    public LispObject nreverse() throws ConditionThrowable
    203203    {
    204204        int i = 0;
     
    211211            --j;
    212212        }
     213        return this;
    213214    }
    214215
Note: See TracChangeset for help on using the changeset viewer.