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

Last change on this file since 35456 was 35456, checked in by Kon Lovett, 17 months ago

begin typing, dep /

File size: 3.1 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 chicken)
25
26(use
27  (only data-structures alist-ref alist-update!)
28  (only srfi-1 alist-cons alist-delete!)
29  (only type-checks define-check+error-type check-procedure check-symbol)
30  source-registration)
31
32#; ;NO YOU 'EFFING MORON
33(use typed-define)
34
35;;;
36
37(include "srfi-27-common-types")
38
39;;;
40
41;;
42
43#; ;NO YOU 'EFFING MORON
44(define:-record-type random-source
45  (*make-random-source
46    ctor
47    name docu
48    log2-period maxrng
49    es
50    state-ref state-set!
51    randomize! pseudo-randomize!
52    make-integers make-reals)
53  random-source?
54  (ctor               @random-source-constructor)
55  (name               *random-source-name)
56  (docu               *random-source-documentation)
57  (log2-period        *random-source-log2-period)
58  (maxrng             *random-source-maximum-range)
59  (es                 *random-source-entropy-source *random-source-entropy-source-set!)
60  (state-ref          @random-source-state-ref)
61  (state-set!         @random-source-state-set!)
62  (randomize!         @random-source-randomize!)
63  (pseudo-randomize!  @random-source-pseudo-randomize!)
64  (make-integers      @random-source-make-integers)
65  (make-reals         @random-source-make-reals) )
66
67(define-record-type random-source
68  (*make-random-source
69    ctor
70    name docu
71    log2-period maxrng
72    es
73    state-ref state-set!
74    randomize! pseudo-randomize!
75    make-integers make-reals)
76  random-source?
77  (ctor               @random-source-constructor)
78  (name               *random-source-name)
79  (docu               *random-source-documentation)
80  (log2-period        *random-source-log2-period)
81  (maxrng             *random-source-maximum-range)
82  (es                 *random-source-entropy-source *random-source-entropy-source-set!)
83  (state-ref          @random-source-state-ref)
84  (state-set!         @random-source-state-set!)
85  (randomize!         @random-source-randomize!)
86  (pseudo-randomize!  @random-source-pseudo-randomize!)
87  (make-integers      @random-source-make-integers)
88  (make-reals         @random-source-make-reals) )
89
90(define-check+error-type random-source)
91
92;; Random Source Constructor Registry
93
94(define +reg+ (make-source-registration 'random-source '()))
95
96(define (registered-random-sources)
97  ((@source-registration-key +reg+)) )
98
99(define (registered-random-source name)
100  ((@source-registration-ref +reg+) name) )
101
102(define (unregister-random-source name)
103  ((@source-registration-deref! +reg+) name) )
104
105(define (register-random-source! name ctor)
106  ((@source-registration-register! +reg+) name ctor) )
107
108) ;module random-source
Note: See TracBrowser for help on using the repository browser.