1 21 22 package org.armedbear.lisp; 23 24 import java.math.BigInteger ; 25 26 public final class logeqv extends Primitive 30 { 31 private logeqv() 32 { 33 super("logeqv","&rest integers"); 34 } 35 36 public LispObject execute() 37 { 38 return Fixnum.MINUS_ONE; 39 } 40 41 public LispObject execute(LispObject arg) throws ConditionThrowable 42 { 43 if (arg instanceof Fixnum) 44 return arg; 45 if (arg instanceof Bignum) 46 return arg; 47 return signal(new TypeError(arg, "integer")); 48 } 49 50 public LispObject execute(LispObject[] args) throws ConditionThrowable 51 { 52 BigInteger result = null; 53 for (int i = 0; i < args.length; i++) { 54 LispObject arg = args[i]; 55 BigInteger n; 56 if (arg instanceof Fixnum) 57 n = ((Fixnum)arg).getBigInteger(); 58 else if (arg instanceof Bignum) 59 n = ((Bignum)arg).getValue(); 60 else 61 return signal(new TypeError(arg, "integer")); 62 if (result == null) 63 result = n; 64 else 65 result = result.xor(n).not(); 66 } 67 return number(result); 68 } 69 70 private static final logeqv LOGEQV = new logeqv(); 71 } 72 | Popular Tags |