Cons(final A head, final F0<Stream<A>> tail) { this.head = head; this.tail = weakMemo(tail); }
/** * Provides a memoising P2 that remembers its values. * * @return A P2 that calls this P2 once for any given element and remembers the value for subsequent calls. */ public final P2<A, B> memo() { P2<A, B> self = this; return new P2<A, B>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); public A _1() { return a._1(); } public B _2() { return b._1(); } }; }
/** * Provides a memoising P3 that remembers its values. * * @return A P3 that calls this P3 once for any given element and remembers the value for subsequent calls. */ public final P3<A, B, C> memo() { P3<A, B, C> self = this; return new P3<A, B, C>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); public A _1() { return a._1(); } public B _2() { return b._1(); } public C _3() { return c._1(); } }; }
/** * @deprecated since 4.7. Use {@link P#weakMemo(F0)} instead. */ @Deprecated public static <A> P1<A> memo(F0<A> f) { return P.weakMemo(f); }
/** * Provides a memoising P4 that remembers its values. * * @return A P4 that calls this P4 once for any given element and remembers the value for subsequent calls. */ public final P4<A, B, C, D> memo() { P4<A, B, C, D> self = this; return new P4<A, B, C, D>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); private final P1<D> d = weakMemo(self::_4); public A _1() { return a._1(); } public B _2() { return b._1(); } public C _3() { return c._1(); } public D _4() { return d._1(); } }; }
/** * Provides a memoising P5 that remembers its values. * * @return A P5 that calls this P5 once for any given element and remembers the value for subsequent calls. */ public final P5<A, B, C, D, E> memo() { P5<A, B, C, D, E> self = this; return new P5<A, B, C, D, E>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); private final P1<D> d = weakMemo(self::_4); private final P1<E> e = weakMemo(self::_5); public A _1() { return a._1(); } public B _2() { return b._1(); } public C _3() { return c._1(); } public D _4() { return d._1(); } public E _5() { return e._1(); } }; }
P6<A, B, C, D, E, F> self = this; return new P6<A, B, C, D, E, F>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); private final P1<D> d = weakMemo(self::_4); private final P1<E> e = weakMemo(self::_5); private final P1<F> f = weakMemo(self::_6);
P7<A, B, C, D, E, F, G> self = this; return new P7<A, B, C, D, E, F, G>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); private final P1<D> d = weakMemo(self::_4); private final P1<E> e = weakMemo(self::_5); private final P1<F> f = weakMemo(self::_6); private final P1<G> g = weakMemo(self::_7);
P8<A, B, C, D, E, F, G, H> self = this; return new P8<A, B, C, D, E, F, G, H>() { private final P1<A> a = weakMemo(self::_1); private final P1<B> b = weakMemo(self::_2); private final P1<C> c = weakMemo(self::_3); private final P1<D> d = weakMemo(self::_4); private final P1<E> e = weakMemo(self::_5); private final P1<F> f = weakMemo(self::_6); private final P1<G> g = weakMemo(self::_7); private final P1<H> h = weakMemo(self::_8);
/** * @deprecated since 4.7. Use {@link P#weakMemo(F0)} instead. */ @Deprecated public static <A> P1<A> memo(F<Unit, A> f) { return P.weakMemo(() -> f.f(unit())); }