1 21 22 package org.armedbear.lisp; 23 24 public final class cxr extends Lisp 25 { 26 private static final Primitive2 _RPLACA = 28 new Primitive2("%rplaca", PACKAGE_SYS, false) 29 { 30 public LispObject execute(LispObject first, LispObject second) 31 throws ConditionThrowable 32 { 33 first.setCar(second); 34 return second; 35 } 36 }; 37 38 private static final Primitive2 _RPLACD = 40 new Primitive2("%rplacd", PACKAGE_SYS, false) 41 { 42 public LispObject execute(LispObject first, LispObject second) 43 throws ConditionThrowable 44 { 45 first.setCdr(second); 46 return second; 47 } 48 }; 49 50 private static final Primitive1 CAR = new Primitive1("car", "list") 52 { 53 public LispObject execute(LispObject arg) throws ConditionThrowable 54 { 55 return arg.car(); 56 } 57 }; 58 59 private static final Primitive1 CDR = new Primitive1("cdr", "list") 61 { 62 public LispObject execute(LispObject arg) throws ConditionThrowable 63 { 64 return arg.cdr(); 65 } 66 }; 67 68 private static final Primitive1 CAAR = new Primitive1("caar", "list") 70 { 71 public LispObject execute(LispObject arg) throws ConditionThrowable 72 { 73 return arg.car().car(); 74 } 75 }; 76 77 private static final Primitive1 CADR = new Primitive1("cadr", "list") 79 { 80 public LispObject execute(LispObject arg) throws ConditionThrowable 81 { 82 return arg.cadr(); 83 } 84 }; 85 86 private static final Primitive1 CDAR = new Primitive1("cdar", "list") 88 { 89 public LispObject execute(LispObject arg) throws ConditionThrowable 90 { 91 return arg.car().cdr(); 92 } 93 }; 94 95 private static final Primitive1 CDDR = new Primitive1("cddr", "list") 97 { 98 public LispObject execute(LispObject arg) throws ConditionThrowable 99 { 100 return arg.cdr().cdr(); 101 } 102 }; 103 104 private static final Primitive1 CADDR = new Primitive1("caddr", "list") 106 { 107 public LispObject execute(LispObject arg) throws ConditionThrowable 108 { 109 return arg.cdr().cdr().car(); 110 } 111 }; 112 113 private static final Primitive1 CAADR = new Primitive1("caadr", "list") 115 { 116 public LispObject execute(LispObject arg) throws ConditionThrowable 117 { 118 return arg.cdr().car().car(); 119 } 120 }; 121 122 private static final Primitive1 CAAAR = new Primitive1("caaar", "list") 124 { 125 public LispObject execute(LispObject arg) throws ConditionThrowable 126 { 127 return arg.car().car().car(); 128 } 129 }; 130 131 private static final Primitive1 CDAAR = new Primitive1("cdaar", "list") 133 { 134 public LispObject execute(LispObject arg) throws ConditionThrowable 135 { 136 return arg.car().car().cdr(); 137 } 138 }; 139 140 private static final Primitive1 CDDAR = new Primitive1("cddar", "list") 142 { 143 public LispObject execute(LispObject arg) throws ConditionThrowable 144 { 145 return arg.car().cdr().cdr(); 146 } 147 }; 148 149 private static final Primitive1 CDDDR = new Primitive1("cdddr", "list") 151 { 152 public LispObject execute(LispObject arg) throws ConditionThrowable 153 { 154 return arg.cdr().cdr().cdr(); 155 } 156 }; 157 158 private static final Primitive1 CADAR = new Primitive1("cadar", "list") 160 { 161 public LispObject execute(LispObject arg) throws ConditionThrowable 162 { 163 return arg.car().cdr().car(); 164 } 165 }; 166 167 private static final Primitive1 CDADR = new Primitive1("cdadr", "list") 169 { 170 public LispObject execute(LispObject arg) throws ConditionThrowable 171 { 172 return arg.cdr().car().cdr(); 173 } 174 }; 175 176 private static final Primitive1 FIRST = new Primitive1("first","list") 178 { 179 public LispObject execute(LispObject arg) throws ConditionThrowable 180 { 181 return arg.car(); 182 } 183 }; 184 185 private static final Primitive1 SECOND = new Primitive1("second","list") 187 { 188 public LispObject execute(LispObject arg) throws ConditionThrowable 189 { 190 return arg.cadr(); 191 } 192 }; 193 194 private static final Primitive1 THIRD = new Primitive1("third","list") 196 { 197 public LispObject execute(LispObject arg) throws ConditionThrowable 198 { 199 return arg.cdr().cdr().car(); 200 } 201 }; 202 203 private static final Primitive1 FOURTH = new Primitive1("fourth","list") 205 { 206 public LispObject execute(LispObject arg) throws ConditionThrowable 207 { 208 return arg.cdr().cdr().cdr().car(); 209 } 210 }; 211 212 private static final Primitive1 REST = new Primitive1("rest","list") 214 { 215 public LispObject execute(LispObject arg) throws ConditionThrowable 216 { 217 return arg.cdr(); 218 } 219 }; 220 } 221 | Popular Tags |