Tweak /dev/random loop to be a little cleaner.
authorChris Hanson <org/chris-hanson/cph>
Mon, 9 Aug 1999 19:33:44 +0000 (19:33 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 9 Aug 1999 19:33:44 +0000 (19:33 +0000)
v7/src/runtime/random.scm

index 1abd81963b73cd7a12cfc42ed34276fdd4768f5a..967f31c1bbe49df44854746e4f54124b2ad0c597 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: random.scm,v 14.21 1999/08/09 19:30:18 cph Exp $
+$Id: random.scm,v 14.22 1999/08/09 19:33:44 cph Exp $
 
 Copyright (c) 1993-1999 Massachusetts Institute of Technology
 
@@ -96,19 +96,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
              (lambda (port)
                (initial-random-state
                 (lambda (b)
-                  (let loop ()
-                    (let ((n
-                           (let loop
-                               ((m #x100)
-                                (n (char->integer (read-char port))))
-                             (if (< m b)
-                                 (loop (* m #x100)
-                                       (+ (* n #x100)
-                                          (char->integer (read-char port))))
-                                 n))))
-                      (if (< n b)
-                          n
-                          (loop))))))))
+                  (let outer ()
+                    (let inner
+                        ((m #x100)
+                         (n (char->integer (read-char port))))
+                      (cond ((< m b)
+                             (inner (* m #x100)
+                                    (+ (* n #x100)
+                                       (char->integer (read-char port)))))
+                            ((< n b) n)
+                            (else (outer)))))))))
            (initial-random-state
             (congruential-rng (+ (real-time-clock) 123456789))))
        (copy-random-state