On Wed, Feb 19, 2014 at 5:02 PM, Neil Toronto <neil.toro...@gmail.com> wrote: > > (: random-natural/no-mean (-> Real Natural)) > (define (random-natural/no-mean prob-zero) > (define n (exact-floor (sample (geometric-dist prob-zero)))) > (define m1 (assert (expt 2 n) integer?)) > (define m0 (quotient m1 2)) > (max 0 (random-integer m0 m1))) > > The "max 0" keeps TR from complaining that `random-integer' returns an > Integer.
These both look like places where `math` could do better here with types. Specifically, `geometric-dist` should probably say that it produces non-negative floats. That would fix the need for the `assert`. Second, `random-integer` could have the type: (case-> (Natural Natural -> Natural) (Integer Integer -> Integer)). That would fix the need for `max`. Finally, I don't understand why `geometric-dist` returns floats and not integers, anyway. Sam ____________________ Racket Users list: http://lists.racket-lang.org/users