aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@axiomatics.org>2015-12-31 13:29:37 -0800
committerGabriel Dos Reis <gdr@axiomatics.org>2015-12-31 13:29:37 -0800
commit039d244dbef31e4ca6d34d2cf42b58b41a572884 (patch)
treea8682ba2deba76a923969a9c92f8f4441703832b /src
parent3fe5ede20d325254817e50d735e9e09c0c875860 (diff)
downloadopen-axiom-039d244dbef31e4ca6d34d2cf42b58b41a572884.tar.gz
Improve 'random()' from Integer domain.
Diffstat (limited to 'src')
-rw-r--r--src/algebra/integer.spad.pamphlet13
-rw-r--r--src/interp/g-opt.boot2
-rw-r--r--src/interp/lisp-backend.boot4
-rw-r--r--src/interp/spad.lisp1
4 files changed, 13 insertions, 7 deletions
diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet
index 789695d6..6838a053 100644
--- a/src/algebra/integer.spad.pamphlet
+++ b/src/algebra/integer.spad.pamphlet
@@ -81,6 +81,8 @@ Integer: IntegerNumberSystem with
import %icst1: % from Foreign Builtin
import %ineg: % -> % from Foreign Builtin
import %iabs: % -> % from Foreign Builtin
+ import %iinc: % -> % from Foreign Builtin
+ import %idec: % -> % from Foreign Builtin
import %irandom: % -> % from Foreign Builtin
import %iodd?: % -> Boolean from Foreign Builtin
import %ieven?: % -> Boolean from Foreign Builtin
@@ -103,17 +105,18 @@ Integer: IntegerNumberSystem with
import %igt: (%,%) -> Boolean from Foreign Builtin
import %ige: (%,%) -> Boolean from Foreign Builtin
import %ilength: % -> % from Foreign Builtin
+ import %ibigrandom: () -> % from Foreign Builtin
import %i2s: % -> String from Foreign Builtin
import %strconc: (String,String) -> String from Foreign Builtin
- zero? x == x = 0$%
- one? x == x = 1$%
0 == %icst0
1 == %icst1
+ zero? x == x = 0$%
+ one? x == x = 1$%
base() == 2 pretend %
copy x == x
- inc x == x + 1$%
- dec x == x - 1$%
+ inc x == %iinc x
+ dec x == %idec x
hash x == %hash x
negative? x == x < 0$%
positive? x == 0$% < x
@@ -147,7 +150,7 @@ Integer: IntegerNumberSystem with
[m pretend Matrix(Integer), v pretend Vector(Integer)]
abs(x) == %iabs x
- random() == random()$Lisp
+ random() == %ibigrandom()
random(x) == %irandom x
x = y == %ieq(x,y)
x < y == %ilt(x,y)
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 4dd126e3..453c972e 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -640,7 +640,7 @@ $VMsideEffectFreeOperators ==
%ilength %ibit %icst0 %icst1 %icstmin %icstmax
%imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc
%idec %irem %iquo %idivide %idec %irandom %imulmod %iaddmod %isubmod
- %ilshift %irshift
+ %ilshift %irshift %ibigrandom
%feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float?
%fpowi %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc
%fsqrt %fpowf %flog %flog2 %flog10 %fmanexp %fNaN? %fdecode
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index 3232f9fe..895f6134 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -276,6 +276,9 @@ expandIlt ['%ilt,x,y] ==
expandIgt ['%igt,x,y] ==
expandIlt ['%ilt,y,x]
+expandIbigrandom ['%ibigrandom] ==
+ ['RANDOM,['GET_-INTERNAL_-REAL_-TIME]]
+
-- Floating point support
expandFbase ['%fbase] ==
@@ -689,6 +692,7 @@ for x in [
['%ilt, :function expandIlt],
['%ineg, :function expandIneg],
['%idivide, :function expandIdivide],
+ ['%ibigrandom, :function expandIbigrandom],
['%i2f, :function expandI2f],
['%fdecode, :function expandFdecode],
diff --git a/src/interp/spad.lisp b/src/interp/spad.lisp
index cd69a95f..f5c30c33 100644
--- a/src/interp/spad.lisp
+++ b/src/interp/spad.lisp
@@ -127,7 +127,6 @@
(define-function '|not| #'NOT)
-(defun |random| () (random (expt 2 26)))
(defun \,plus (x y) (+ x y))
(defun \,times (x y) (* x y))
(defun \,difference (x y) (- x y))