Fix object name for new random function.

This commit is contained in:
Vincent St-Amour 2016-01-03 12:58:50 -06:00
parent 1e18a7e2b4
commit 4509430063

View File

@ -112,34 +112,36 @@
y)))) y))))
(begin-encourage-inline (begin-encourage-inline
(define-values (-random) ; more featureful than #%kernel's `random` (define-values (-random) ; more featureful than #%kernel's `random`
(case-lambda (procedure-rename
[() (random)] ; no args, random float (case-lambda
[(x) ; one arg, either random float with prng, or random integer [() (random)] ; no args, random float
;; can just pass through to #%kernel's `random`, which will do the [(x) ; one arg, either random float with prng, or random integer
;; necessary checking ;; can just pass through to #%kernel's `random`, which will do the
(random x)] ;; necessary checking
[(x y) (random x)]
;; two args, either max and prng, or min and max [(x y)
(cond [(exact-positive-integer? y) ; min and max case ;; two args, either max and prng, or min and max
(enforce-random-int-range x) (cond [(exact-positive-integer? y) ; min and max case
(enforce-random-int-range y) (enforce-random-int-range x)
(enforce-greater x y) (enforce-random-int-range y)
(+ x (random (- y x)))] (enforce-greater x y)
[(pseudo-random-generator? y) ; int and prng case (+ x (random (- y x)))]
(enforce-random-int-range x) [(pseudo-random-generator? y) ; int and prng case
(random x y)] (enforce-random-int-range x)
[else (random x y)]
(raise-argument-error [else
'random (raise-argument-error
"(or/c (integer-in 1 4294967087) pseudo-random-generator?)" 'random
y)])] "(or/c (integer-in 1 4294967087) pseudo-random-generator?)"
[(min max prng) ; three args: min, max, and prng y)])]
(enforce-random-int-range min) [(min max prng) ; three args: min, max, and prng
(enforce-random-int-range max) (enforce-random-int-range min)
(enforce-greater min max) (enforce-random-int-range max)
(unless (pseudo-random-generator? prng) (enforce-greater min max)
(raise-argument-error 'random "pseudo-random-generator?" prng)) (unless (pseudo-random-generator? prng)
(+ min (random (- max min) prng))]))) (raise-argument-error 'random "pseudo-random-generator?" prng))
(+ min (random (- max min) prng))])
'random)))
(define-values (new:collection-path) (define-values (new:collection-path)
(let ([collection-path (new-lambda (collection (let ([collection-path (new-lambda (collection