add conditional

This commit is contained in:
Yadunand Prem
2022-10-15 23:13:06 +08:00
parent 04f923a4ca
commit 6a4ef4ea70
4 changed files with 28 additions and 17 deletions

View File

@@ -28,6 +28,10 @@ public class Memo<T> extends Lazy<T> {
return result;
}
public <R, S> Memo<R> combine(Memo<? extends S> other, Combiner<? extends R, ? super T, ? super S> combiner) {
return Memo.<R>from(() -> combiner.combine(this.get(), other.get()));
}
@Override
public <R> Memo<R> transform(Immutator<? extends R, ? super T> f) {
return Memo.<R>from(() -> f.invoke(this.get()));