Skip to content

Commit bef50e6

Browse files
committed
Added hard memo. Default memo to soft
1 parent 7b170be commit bef50e6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

core/src/main/java/fj/P1.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,16 @@ public <X> P1<X> map(final F<A, X> f) {
209209
return P.lazy(() -> f.f(self._1()));
210210
}
211211

212+
public P1<A> memo() {
213+
return softMemo();
214+
}
215+
212216
/**
213217
* Returns a P1 that remembers its value.
214218
*
215219
* @return A P1 that calls this P1 once and remembers the value for subsequent calls.
216220
*/
217-
public P1<A> memo() { return new Memo<>(this); }
221+
public P1<A> hardMemo() { return new Memo<>(this); }
218222

219223
/**
220224
* Like <code>memo</code>, but the memoized value is wrapped into a <code>WeakReference</code>

core/src/main/java/fj/data/Stream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ private static final class Cons<A> extends Stream<A> {
14951495

14961496
Cons(final A head, final P1<Stream<A>> tail) {
14971497
this.head = head;
1498-
this.tail = tail.weakMemo();
1498+
this.tail = tail.memo();
14991499
}
15001500

15011501
public A head() {

0 commit comments

Comments
 (0)