home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d3xx
/
d385
/
xlispstat.lha
/
XLispStat
/
lisp.lzh
/
XLisp-Stat
/
Book
/
randu.lsp
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
Lisp/Scheme
|
1990-10-11
|
389 b
|
14 lines
; book p.41
(defun randu (n &optional (seed 12345))
(let ((a (+ (^ 2 16) 3))
(m (^ 2 31)))
(flet ((mod (x m) (- x (* m (floor (/ x m))))))
(do ((i 0 (+ i 1))
(res (list seed)
(cons (mod (* a (first res)) m) res)))
((>= i n)
(/ (rest (reverse res)) m))))))
(def randu (apply #'mapcar #'list (split-list (randu 300) 3)))