@Test public void testTrampolineWithFactorialFunction() throws IOException { int result = TrampolineApp.loop(10, 1).result(); assertEquals("Be equal", 3628800, result); }
public static Trampoline<Integer> loop(int times, int prod) { if (times == 0) { return Trampoline.done(prod); } else { return Trampoline.more(() -> loop(times - 1, prod * times)); } }
TrampolineApp { public static Trampoline<Integer> loop(int times, int prod) { if (times == 0) { return Trampoline.done(prod); } else { return Trampoline.more(() -> loop(times - 1, prod * times)); } } }
TrampolineApp { public static Trampoline<Integer> loop(int times, int prod) { if (times == 0) { return Trampoline.done(prod); } else { return Trampoline.more(() -> loop(times - 1, prod * times)); } }  }
TrampolineApp { public static Trampoline<Integer> loop(int times, int prod) { if (times == 0) { return Trampoline.done(prod); } else { return Trampoline.more(() -> loop(times - 1, prod * times)); } }  static void main(String[] args); static Trampoline<Integer> loop(int times, int prod); }
TrampolineApp { public static Trampoline<Integer> loop(int times, int prod) { if (times == 0) { return Trampoline.done(prod); } else { return Trampoline.more(() -> loop(times - 1, prod * times)); } }  static void main(String[] args); static Trampoline<Integer> loop(int times, int prod);  }