-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpar-nested-rand.scm
39 lines (29 loc) · 932 Bytes
/
par-nested-rand.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(import (owl random))
(define-syntax lets (syntax-rules () ((lets . stuff) (let* . stuff)))) ; TEMP
(define (small-range? lo hi)
(< (- hi lo) 100))
(define (seek rs lo hi n)
(if (small-range? lo hi)
(if (has? (lrange lo 1 hi) n)
(begin
(print "found it!")
#true)
#false)
(lets
((rs mid (rand-range rs lo hi))
(rs a (rand rs 3)) ;; delays for thread stepping randomization
(rs b (rand rs 3))
(rs seed (rand rs #xfffffffffff)) ;; new seed for new random state in the other branch
(rsp (seed->rands seed)))
(por
(begin
(seek rs lo mid n))
(begin
(seek rsp mid hi n))))))
(define seed (time-ms))
(define rs (seed->rands seed))
(define lo 0)
(define hi 10000)
(define-values (rs needle) (rand-range rs lo hi))
(print "looking...")
(seek rs lo hi needle)