randomInt function

IO<int> randomInt(
  1. int min,
  2. int max
)

Generates a non-negative random integer uniformly distributed in the range from min, inclusive, to max, exclusive.

Implementation

IO<int> randomInt(int min, int max) =>
    IO(() => Random().nextInt(max - min) + min);