001: /*
002: * cxr.java
003: *
004: * Copyright (C) 2003-2004 Peter Graves
005: * $Id: cxr.java,v 1.6 2004/09/03 19:04:29 piso Exp $
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021:
022: package org.armedbear.lisp;
023:
024: public final class cxr extends Lisp {
025: // ### %rplaca
026: private static final Primitive2 _RPLACA = new Primitive2("%rplaca",
027: PACKAGE_SYS, false) {
028: public LispObject execute(LispObject first, LispObject second)
029: throws ConditionThrowable {
030: first.setCar(second);
031: return second;
032: }
033: };
034:
035: // ### %rplacd
036: private static final Primitive2 _RPLACD = new Primitive2("%rplacd",
037: PACKAGE_SYS, false) {
038: public LispObject execute(LispObject first, LispObject second)
039: throws ConditionThrowable {
040: first.setCdr(second);
041: return second;
042: }
043: };
044:
045: // ### car
046: private static final Primitive1 CAR = new Primitive1("car", "list") {
047: public LispObject execute(LispObject arg)
048: throws ConditionThrowable {
049: return arg.car();
050: }
051: };
052:
053: // ### cdr
054: private static final Primitive1 CDR = new Primitive1("cdr", "list") {
055: public LispObject execute(LispObject arg)
056: throws ConditionThrowable {
057: return arg.cdr();
058: }
059: };
060:
061: // ### caar
062: private static final Primitive1 CAAR = new Primitive1("caar",
063: "list") {
064: public LispObject execute(LispObject arg)
065: throws ConditionThrowable {
066: return arg.car().car();
067: }
068: };
069:
070: // ### cadr
071: private static final Primitive1 CADR = new Primitive1("cadr",
072: "list") {
073: public LispObject execute(LispObject arg)
074: throws ConditionThrowable {
075: return arg.cadr();
076: }
077: };
078:
079: // ### cdar
080: private static final Primitive1 CDAR = new Primitive1("cdar",
081: "list") {
082: public LispObject execute(LispObject arg)
083: throws ConditionThrowable {
084: return arg.car().cdr();
085: }
086: };
087:
088: // ### cddr
089: private static final Primitive1 CDDR = new Primitive1("cddr",
090: "list") {
091: public LispObject execute(LispObject arg)
092: throws ConditionThrowable {
093: return arg.cdr().cdr();
094: }
095: };
096:
097: // ### caddr
098: private static final Primitive1 CADDR = new Primitive1("caddr",
099: "list") {
100: public LispObject execute(LispObject arg)
101: throws ConditionThrowable {
102: return arg.cdr().cdr().car();
103: }
104: };
105:
106: // ### caadr
107: private static final Primitive1 CAADR = new Primitive1("caadr",
108: "list") {
109: public LispObject execute(LispObject arg)
110: throws ConditionThrowable {
111: return arg.cdr().car().car();
112: }
113: };
114:
115: // ### caaar
116: private static final Primitive1 CAAAR = new Primitive1("caaar",
117: "list") {
118: public LispObject execute(LispObject arg)
119: throws ConditionThrowable {
120: return arg.car().car().car();
121: }
122: };
123:
124: // ### cdaar
125: private static final Primitive1 CDAAR = new Primitive1("cdaar",
126: "list") {
127: public LispObject execute(LispObject arg)
128: throws ConditionThrowable {
129: return arg.car().car().cdr();
130: }
131: };
132:
133: // ### cddar
134: private static final Primitive1 CDDAR = new Primitive1("cddar",
135: "list") {
136: public LispObject execute(LispObject arg)
137: throws ConditionThrowable {
138: return arg.car().cdr().cdr();
139: }
140: };
141:
142: // ### cdddr
143: private static final Primitive1 CDDDR = new Primitive1("cdddr",
144: "list") {
145: public LispObject execute(LispObject arg)
146: throws ConditionThrowable {
147: return arg.cdr().cdr().cdr();
148: }
149: };
150:
151: // ### cadar
152: private static final Primitive1 CADAR = new Primitive1("cadar",
153: "list") {
154: public LispObject execute(LispObject arg)
155: throws ConditionThrowable {
156: return arg.car().cdr().car();
157: }
158: };
159:
160: // ### cdadr
161: private static final Primitive1 CDADR = new Primitive1("cdadr",
162: "list") {
163: public LispObject execute(LispObject arg)
164: throws ConditionThrowable {
165: return arg.cdr().car().cdr();
166: }
167: };
168:
169: // ### first
170: private static final Primitive1 FIRST = new Primitive1("first",
171: "list") {
172: public LispObject execute(LispObject arg)
173: throws ConditionThrowable {
174: return arg.car();
175: }
176: };
177:
178: // ### second
179: private static final Primitive1 SECOND = new Primitive1("second",
180: "list") {
181: public LispObject execute(LispObject arg)
182: throws ConditionThrowable {
183: return arg.cadr();
184: }
185: };
186:
187: // ### third
188: private static final Primitive1 THIRD = new Primitive1("third",
189: "list") {
190: public LispObject execute(LispObject arg)
191: throws ConditionThrowable {
192: return arg.cdr().cdr().car();
193: }
194: };
195:
196: // ### fourth
197: private static final Primitive1 FOURTH = new Primitive1("fourth",
198: "list") {
199: public LispObject execute(LispObject arg)
200: throws ConditionThrowable {
201: return arg.cdr().cdr().cdr().car();
202: }
203: };
204:
205: // ### rest
206: private static final Primitive1 REST = new Primitive1("rest",
207: "list") {
208: public LispObject execute(LispObject arg)
209: throws ConditionThrowable {
210: return arg.cdr();
211: }
212: };
213: }
|