com.jnape.palatable.lambda.functions.builtin.fn2

## Class LazyRec<A,B>

- java.lang.Object
- - com.jnape.palatable.lambda.functions.builtin.fn2.LazyRec<A,B>

- Type Parameters:
    `A` - the input type
    `B` - the output type
  All Implemented Interfaces:
    Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>>, Fn2<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,A,Lazy<B>>, Applicative<Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>, Cartesian<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>,Fn1<?,?>>, Cocartesian<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>,Fn1<?,?>>, Contravariant<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Profunctor<?,Fn1<A,Lazy<B>>,Fn1<?,?>>>, Functor<Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>, Profunctor<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>,Fn1<?,?>>, Monad<Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>, MonadReader<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>, MonadRec<Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>, MonadWriter<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,Fn1<A,Lazy<B>>,Fn1<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,?>>

      public final class LazyRec<A,B>
      extends Object
      implements Fn2<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,A,Lazy<B>>

  Given a `Fn2` that receives a recursive function and an input and yields a `lazy` result, and an input, produce a `lazy` result that, when forced, will recursively invoke the function until it terminates in a stack-safe way.

  Example:

       Lazy<BigInteger> lazyFactorial = lazyRec((fact, x) -&gt; x.equals(ONE)
                                                             ? lazy(x)
                                                             : fact.apply(x.subtract(ONE)).fmap(y -&gt; y.multiply(x)),
                                                        BigInteger.valueOf(50_000));
       BigInteger value = lazyFactorial.value(); // 3.34732050959714483691547609407148647791277322381045 x 10^213236

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Lazy<B>` | `checkedApply(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn, A a)`
    `static <A,B> LazyRec<A,B>` | `lazyRec()`
    `static <A,B> Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>` | `lazyRec(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn)`
    `static <A,B> Lazy<B>` | `lazyRec(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn, A a)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functions.Fn2

      `apply, apply, checkedApply, compose, contraMap, curried, curry, diMapL, discardR, flip, fn2, fromBiFunction, toBiFunction, uncurry, widen`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functions.Fn1

      `andThen, carry, cartesian, censor, choose, cocartesian, diMap, diMapR, discardL, flatMap, fmap, fn1, fromFunction, lazyZip, listens, local, pure, pureFn1, thunk, toFunction, trampolineM, zip, zip`

    - ### Methods inherited from interface com.jnape.palatable.lambda.monad.Monad

      `join`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

      `coerce`

- - ### Method Detail

    - #### checkedApply

          public Lazy<B> checkedApply(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn,
                                      A a)

      Specified by:
        `checkedApply` in interface `Fn2<Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>>,A,Lazy<B>>`

    - #### lazyRec

          public static <A,B> LazyRec<A,B> lazyRec()

    - #### lazyRec

          public static <A,B> Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>> lazyRec(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn)

    - #### lazyRec

          public static <A,B> Lazy<B> lazyRec(Fn2<Kleisli<? super A,? extends B,Lazy<?>,Lazy<B>>,A,Lazy<B>> fn,
                                              A a)