CLEAN limit impl

This commit is contained in:
Yadunand Prem
2022-11-02 11:16:17 +08:00
parent 852f48d522
commit b9ae7cfff2

View File

@@ -60,19 +60,10 @@ public class InfiniteList<T> {
return InfiniteList.end(); return InfiniteList.end();
} }
/* Memo<InfiniteList<T>> tail = Memo.from(
* next tail -> () -> this.head.get()
* get the current tail .transform(h -> this.tail.get().limit(n - 1))
* check if actually.err(). If actually.err() then return limit(n). If ok() .except(() -> this.tail.get().limit(n)));
* return limit - 1
*/
Memo<InfiniteList<T>> tail = Memo.from(() -> {
if (this.head.get().unless(null) == null) {
return this.tail.get().limit(n);
}
return this.tail.get().limit(n - 1);
});
return new InfiniteList<>(this.head, tail); return new InfiniteList<>(this.head, tail);
} }