(define nra (make-vector 2)) (define (r k) (if (> k 0) (let* ( (a 0) (nextrandom (lambda () (set! a (modulo (+ (* a 23) 3) 1000)) a))) (vector-set! nra (- k 1) nextrandom) (r (- k 1))) (begin (write(list ((vector-ref nra 0)) ((vector-ref nra 0)) ((vector-ref nra 0)))) (write(list ((vector-ref nra 1)) ((vector-ref nra 1)) ((vector-ref nra 1)))) ((vector-ref nra 1)) (let lp ((n 0)) (if (not (= ((vector-ref nra 0)) ((vector-ref nra 1)))) (begin ((vector-ref nra 1)) (lp (+ n 1))) (write n)))) )) (r 2) ; => (3 72 659)(3 72 659)99 ; Alternatively (let* ((mi (lambda() (let ((a 0)) (lambda () (set! a (modulo (+ (* a 23) 3) 1000)) a)))) (a (mi))(b (mi))) (write(list (a) (a) (a))) (write(list (b) (b) (b))) (b) (let lp ((n 0)) (if (not (= (a) (b))) (begin (b) (lp (+ n 1))) n)))