package org.xander.behavioral.lazyevaluation;

@FunctionalInterface
public interface TailCall<T> {
    TailCall<T> apply();
    default boolean isComplete() { return false; }
    default T result() { throw new Error("not implemented"); }
    default T invoke() {
        return Stream.iterate(this, TailCall::apply)
                     .filter(TailCall::isComplete)
                     .findFirst()
                     .get()
                     .result();
    } 
}

@@ -40,16 +40,49 @@
 ation;%0A%0A
+import java.util.stream.Stream;%0A%0A
 @Functio

Update TailCall.java