source: project/release/4/srfi-27/trunk/random-source.scm @ 34967

Last change on this file since 34967 was 34967, checked in by Kon Lovett, 21 months ago

a mission needs support . common test runner .

File size: 3.2 KB
Line 
1;;;; random-source.scm
2;;;; Kon Lovett, Oct '09
3
4(module random-source
5
6(;export
7  *make-random-source
8  random-source? check-random-source error-random-source
9  *random-source-name
10  *random-source-documentation
11  *random-source-log2-period
12  *random-source-maximum-range
13  *random-source-entropy-source *random-source-entropy-source-set!
14  @random-source-constructor
15  @random-source-state-ref @random-source-state-set!
16  @random-source-randomize! @random-source-pseudo-randomize!
17  @random-source-make-integers @random-source-make-reals
18  ;
19  registered-random-sources
20  registered-random-source
21  unregister-random-source
22  register-random-source!)
23
24(import scheme)
25
26(import chicken)
27
28(import
29  (only data-structures alist-ref alist-update!)
30  (only srfi-1 alist-cons alist-delete!)
31  (only type-checks define-check+error-type check-procedure check-symbol))
32(require-library data-structures srfi-1 type-checks)
33
34(use source-registration)
35
36#; ;NO YOU 'EFFING MORON
37(use typed-define)
38
39;;
40
41#; ;NO YOU 'EFFING MORON
42(define:-record-type random-source
43  (*make-random-source
44    ctor
45    name docu
46    log2-period maxrng
47    es
48    state-ref state-set!
49    randomize! pseudo-randomize!
50    make-integers make-reals)
51  random-source?
52  (ctor               @random-source-constructor)
53  (name               *random-source-name)
54  (docu               *random-source-documentation)
55  (log2-period        *random-source-log2-period)
56  (maxrng             *random-source-maximum-range)
57  (es                 *random-source-entropy-source *random-source-entropy-source-set!)
58  (state-ref          @random-source-state-ref)
59  (state-set!         @random-source-state-set!)
60  (randomize!         @random-source-randomize!)
61  (pseudo-randomize!  @random-source-pseudo-randomize!)
62  (make-integers      @random-source-make-integers)
63  (make-reals         @random-source-make-reals) )
64(define-record-type random-source
65  (*make-random-source
66    ctor
67    name docu
68    log2-period maxrng
69    es
70    state-ref state-set!
71    randomize! pseudo-randomize!
72    make-integers make-reals)
73  random-source?
74  (ctor               @random-source-constructor)
75  (name               *random-source-name)
76  (docu               *random-source-documentation)
77  (log2-period        *random-source-log2-period)
78  (maxrng             *random-source-maximum-range)
79  (es                 *random-source-entropy-source *random-source-entropy-source-set!)
80  (state-ref          @random-source-state-ref)
81  (state-set!         @random-source-state-set!)
82  (randomize!         @random-source-randomize!)
83  (pseudo-randomize!  @random-source-pseudo-randomize!)
84  (make-integers      @random-source-make-integers)
85  (make-reals         @random-source-make-reals) )
86
87(define-check+error-type random-source)
88
89;; Random Source Constructor Registry
90
91(define +reg+ (make-source-registration 'random-source '()))
92
93(define (registered-random-sources)
94  ((@source-registration-key +reg+)) )
95
96(define (registered-random-source name)
97  ((@source-registration-ref +reg+) name) )
98
99(define (unregister-random-source name)
100  ((@source-registration-deref! +reg+) name) )
101
102(define (register-random-source! name ctor)
103  ((@source-registration-register! +reg+) name ctor) )
104
105) ;module random-source
Note: See TracBrowser for help on using the repository browser.