#lang scheme
(define (make-dice sides cumulative?)
(letrec ([roll (if cumulative?
(lambda ([generator (current-pseudo-random-generator)])
(let ([result (+ (random sides generator) 1)])
(if (= result sides)
(+ result (roll generator))
result)))
(lambda ([generator (current-pseudo-random-generator)])
(+ (random sides generator) 1)))])
roll))
(provide/contract [make-dice (-> exact-positive-integer?
any/c
(->* ()
(pseudo-random-generator?)
exact-positive-integer?))])
(define (fact n)
(for/fold ([f 1]) ([i (in-range 1 (+ n 1))])
(* f i)))
(provide/contract [fact (-> exact-nonnegative-integer?
exact-positive-integer?)])
(define-struct test-result
(successful? critical? value)
#:transparent)
(provide/contract (struct test-result
([successful? boolean?]
[critical? boolean?]
[value any/c])))
(define-struct test-statistics
(successful critical expectation)
#:transparent)
(provide/contract (struct test-statistics
([successful (real-in 0 1)]
[critical (real-in 0 1)]
[expectation any/c])))