Changeset 3485


Ignore:
Timestamp:
08/24/03 17:26:24 (19 years ago)
Author:
piso
Message:

REALPART, IMAGPART

File:
1 edited

Legend:

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

    r3481 r3485  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.343 2003-08-24 16:23:22 piso Exp $
     5 * $Id: Primitives.java,v 1.344 2003-08-24 17:26:24 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    47884788        }
    47894789    };
     4790
     4791    // ### realpart
     4792    private static final Primitive1 REALPART = new Primitive1("realpart")
     4793    {
     4794        public LispObject execute(LispObject arg) throws LispError
     4795        {
     4796            if (arg instanceof Complex)
     4797                return ((Complex)arg).getRealPart();
     4798            if ((arg.getType() & TYPE_NUMBER) != 0)
     4799                return arg;
     4800            throw new TypeError(arg, "number");
     4801        }
     4802    };
     4803
     4804    // ### imagpart
     4805    private static final Primitive1 IMAGPART = new Primitive1("imagpart")
     4806    {
     4807        public LispObject execute(LispObject arg) throws LispError
     4808        {
     4809            if (arg instanceof Complex)
     4810                return ((Complex)arg).getImaginaryPart();
     4811            return arg.multiplyBy(Fixnum.ZERO);
     4812        }
     4813    };
    47904814}
Note: See TracChangeset for help on using the changeset viewer.