diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/algebra/integer.spad.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/sex.spad.pamphlet | 23 | ||||
-rw-r--r-- | src/algebra/strap/INT.lsp | 13 | ||||
-rw-r--r-- | src/algebra/syntax.spad.pamphlet | 4 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 6 |
5 files changed, 30 insertions, 18 deletions
diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet index ffcb0206..da23d678 100644 --- a/src/algebra/integer.spad.pamphlet +++ b/src/algebra/integer.spad.pamphlet @@ -145,7 +145,7 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with inc x == x + 1 dec x == x - 1 hash x == %hash x - negative? x == MINUSP(x)$Lisp + negative? x == x < 0 coerce(x):OutputForm == outputForm(x pretend Integer) coerce(m:Integer):% == m pretend % convert(x:%):Integer == x pretend Integer diff --git a/src/algebra/sex.spad.pamphlet b/src/algebra/sex.spad.pamphlet index bb5df1f5..2beef473 100644 --- a/src/algebra/sex.spad.pamphlet +++ b/src/algebra/sex.spad.pamphlet @@ -94,6 +94,13 @@ SExpressionOf(Str, Sym, Int, Flt, Expr): Decl == Body where Decl ==> SExpressionCategory(Str, Sym, Int, Flt, Expr) Body ==> add + import %integer?: % -> Boolean from Foreign Builtin + import %string?: % -> Boolean from Foreign Builtin + import %pair?: % -> Boolean from Foreign Builtin + import %peq: (%,%) -> Boolean from Foreign Builtin + import %head: % -> % from Foreign Builtin + import %tail: % -> % from Foreign Builtin + Rep := Expr dotex:OutputForm := INTERN(".")$Lisp @@ -112,20 +119,20 @@ SExpressionOf(Str, Sym, Int, Flt, Expr): Decl == Body where paren blankSeparate l1 b1 = b2 == EQUAL(b1,b2)$Lisp - eq(b1, b2) == %peq(b1,b2)$Foreign(Builtin) + eq(b1, b2) == %peq(b1,b2) null? b == NULL(b)$Lisp atom? b == ATOM(b)$Lisp - pair? b == PAIRP(b)$Lisp + pair? b == %pair? b - list? b == PAIRP(b)$Lisp or NULL(b)$Lisp - string? b == STRINGP(b)$Lisp + list? b == pair? b or null? b + string? b == %string? b symbol? b == IDENTP(b)$Lisp - integer? b == INTP(b)$Lisp + integer? b == %integer? b float? b == RNUMP(b)$Lisp destruct b == (list? b => b pretend List %; error "Non-list") - string b == (STRINGP(b)$Lisp=> b pretend Str;error "Non-string") + string b == (%string? b => b pretend Str; error "Non-string") symbol b == (IDENTP(b)$Lisp => b pretend Sym;error "Non-symbol") float b == (RNUMP(b)$Lisp => b pretend Flt;error "Non-float") integer b == (INTP(b)$Lisp => b pretend Int;error "Non-integer") @@ -138,8 +145,8 @@ SExpressionOf(Str, Sym, Int, Flt, Expr): Decl == Body where convert(f: Flt) == f pretend % convert(e: Expr) == e pretend % - car b == CAR(b)$Lisp - cdr b == CDR(b)$Lisp + car b == %head b + cdr b == %tail b # b == LENGTH(b)$Lisp elt(b:%, i:Integer) == destruct(b).i elt(b:%, li:List Integer) == diff --git a/src/algebra/strap/INT.lsp b/src/algebra/strap/INT.lsp index c294d8df..5c5fe790 100644 --- a/src/algebra/strap/INT.lsp +++ b/src/algebra/strap/INT.lsp @@ -56,8 +56,6 @@ (DECLAIM (FTYPE (FUNCTION (|%Integer| |%Shell|) |%Boolean|) |INT;negative?;$B;15|)) -(PUT '|INT;negative?;$B;15| '|SPADreplace| 'MINUSP) - (DECLAIM (FTYPE (FUNCTION (|%Integer| |%Shell|) |%Thing|) |INT;coerce;$Of;16|)) @@ -263,6 +261,9 @@ (PUT '|INT;dec;2$;13| '|SPADreplace| '(XLAM (|x|) (|%isub| |x| 1))) +(PUT '|INT;negative?;$B;15| '|SPADreplace| + '(XLAM (|x|) (|%ilt| |x| 0))) + (PUT '|INT;unitCanonical;2$;55| '|SPADreplace| '|%iabs|) (DEFUN |INT;writeOMInt| (|dev| |x| $) @@ -372,8 +373,10 @@ (PROG (|r|) (RETURN (COND - ((MINUSP (LETT |r| (REMAINDER2 |a| |b|) - |INT;positiveRemainder;3$;28|)) + ((|INT;negative?;$B;15| + (LETT |r| (REMAINDER2 |a| |b|) + |INT;positiveRemainder;3$;28|) + $) (COND ((MINUSP |b|) (- |r| |b|)) ('T (+ |r| |b|)))) ('T |r|))))) @@ -498,7 +501,7 @@ (DEFUN |Integer| () (DECLARE (SPECIAL |$ConstructorCache|)) - (PROG (#0=#:G1527) + (PROG (#0=#:G1528) (RETURN (COND ((SETQ #0# (HGET |$ConstructorCache| '|Integer|)) diff --git a/src/algebra/syntax.spad.pamphlet b/src/algebra/syntax.spad.pamphlet index a8d6c7a3..9856a21d 100644 --- a/src/algebra/syntax.spad.pamphlet +++ b/src/algebra/syntax.spad.pamphlet @@ -625,6 +625,8 @@ ParameterAst(): Public == Private where ++ object \spad{x} to \spadtype{String}. This function ++ is left at the discretion of the compiler. Private == add + import %string?: % -> Boolean from Foreign Builtin + x case Identifier == SYMBOLP(x)$Foreign(Builtin) @@ -632,7 +634,7 @@ ParameterAst(): Public == Private where x : Identifier x case String == - STRINGP(x)$Foreign(Builtin) + %string? x autoCoerce(x: %): String == x : String diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 1c8964f6..7e4b8443 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -474,9 +474,9 @@ optLESSP u == $VMsideEffectFreeOperators == '(CAR CDR LENGTH SIZE EQUAL EQL EQ NOT NULL OR AND SPADfirst QVELT _+ _- _* _< _= _<_= _> _>_= ASH INTEGER_-LENGTH - QEQCAR QCDR QCAR INTEGERP FLOATP STRINGP IDENTP SYMBOLP - MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN FLOAT_-DIGITS - CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER %false %true + QEQCAR QCDR QCAR IDENTP SYMBOLP + MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN + CGREATERP GGREATERP CHAR GET BVEC_-GREATER %false %true %and %or %not %peq %ieq %ilt %ile %igt %ige %head %tail %integer? %beq %blt %ble %bgt %bge %bitand %bitior %bitnot %bcompl %imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc |