예제 #1
0
 private static Tuple<List<Integer>, RNG> intsHelper(int count, RNG rng) {
   Tuple<Integer, RNG> t1 = rng.nextInt();
   Tuple<List<Integer>, RNG> t2 = ints(count - 1, t1._2);
   return new Tuple<>(t2._1.cons(t1._1), t2._2);
 }
예제 #2
0
 public static Tuple<Tuple<Integer, Double>, RNG> intDouble(RNG rng) {
   Tuple<Integer, RNG> t1 = rng.nextInt();
   Tuple<Double, RNG> t2 = doubleRnd(t1._2);
   return new Tuple<>(new Tuple<>(t1._1, t2._1), t2._2);
 }
예제 #3
0
 public static Tuple<Integer, RNG> nonNegativeInt(RNG rng) {
   Tuple<Integer, RNG> t = rng.nextInt();
   return new Tuple<>((t._1 < 0) ? -(t._1 + 1) : t._1, t._2);
 }
예제 #4
0
 public static Tuple<Boolean, RNG> booleanRnd(RNG rng) {
   Tuple<Integer, RNG> t = rng.nextInt();
   return new Tuple<>(t._1 % 2 == 0, t._2);
 }
예제 #5
0
 private static TailCall<Tuple<List<Integer>, RNG>> ints2Helper(
     int count, RNG rng, List<Integer> xs) {
   Tuple<Integer, RNG> t1 = rng.nextInt();
   return TailCall.sus(() -> ints2(count - 1, t1._2, xs.cons(t1._1)));
 }