Commit 96ed695b authored by pysaumont's avatar pysaumont
Browse files

Post review edited chapter 4

parent 05ade4c9
......@@ -11,7 +11,7 @@ public abstract class TailCall<T> {
private TailCall() {
}
public static class Return<T> extends TailCall<T> {
private static class Return<T> extends TailCall<T> {
private final T t;
......@@ -35,7 +35,7 @@ public abstract class TailCall<T> {
}
}
public static class Suspend<T> extends TailCall<T> {
private static class Suspend<T> extends TailCall<T> {
private final Supplier<TailCall<T>> resume;
......
......@@ -10,7 +10,7 @@ public abstract class TailCall<T> {
public abstract boolean isSuspend();
public static class Return<T> extends TailCall<T> {
private static class Return<T> extends TailCall<T> {
private final T t;
......@@ -34,7 +34,7 @@ public abstract class TailCall<T> {
}
}
public static class Suspend<T> extends TailCall<T> {
private static class Suspend<T> extends TailCall<T> {
private final Supplier<TailCall<T>> resume;
......@@ -69,4 +69,4 @@ public abstract class TailCall<T> {
public static <T> Suspend<T> sus(Supplier<TailCall<T>> s) {
return new Suspend<>(s);
}
}
\ No newline at end of file
}
......@@ -9,11 +9,11 @@ public abstract class TailCall<T> {
public abstract T eval();
public abstract boolean isSuspend();
private TailCall() {
}
public static class Return<T> extends TailCall<T> {
private static class Return<T> extends TailCall<T> {
private final T t;
......@@ -37,7 +37,7 @@ public abstract class TailCall<T> {
}
}
public static class Suspend<T> extends TailCall<T> {
private static class Suspend<T> extends TailCall<T> {
private final Supplier<TailCall<T>> resume;
......@@ -72,4 +72,4 @@ public abstract class TailCall<T> {
public static <T> Suspend<T> sus(Supplier<TailCall<T>> s) {
return new Suspend<>(s);
}
}
\ No newline at end of file
}
......@@ -11,7 +11,7 @@ public class AddTest {
@Test
public void test() {
TailCall<Integer> tailCall = Add.add(3, 100000000);
while(tailCall .isSuspend()) {
while(tailCall.isSuspend()) {
tailCall = tailCall.resume();
}
assertEquals(Integer.valueOf(100000003), tailCall.eval());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment