com.jnape.palatable.lambda.functions.recursion

## Class Trampoline<A,B>

- java.lang.Object
- - com.jnape.palatable.lambda.functions.recursion.Trampoline<A,B>

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

      public final class Trampoline<A,B>
      extends Object
      implements Fn2<Fn1<? super A,? extends RecursiveResult<A,B>>,A,B>

  Given an ``Fn1`<A, `CoProduct2`<A, B, ?>>` (analogous to "recurse" and "return" tail position instructions, respectively), produce a ``Fn1`<A, B>` that unrolls the original function by iteratively passing each result that matches the input (`A`) back to the original function, and then terminating on and returning the first output (`B`).

  This is isomorphic to - though presumably faster than - taking the last element of an `Unfoldr` call.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Trampoline()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `B` | `checkedApply(Fn1<? super A,? extends RecursiveResult<A,B>> fn, A a)`
    `static <A,B> Trampoline<A,B>` | `trampoline()`
    `static <A,B> Fn1<A,B>` | `trampoline(Fn1<? super A,? extends RecursiveResult<A,B>> fn)`
    `static <A,B> B` | `trampoline(Fn1<? super A,? extends RecursiveResult<A,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`

- - ### Constructor Detail

    - #### Trampoline

          public Trampoline()

  - ### Method Detail

    - #### checkedApply

          public B checkedApply(Fn1<? super A,? extends RecursiveResult<A,B>> fn,
                                A a)

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

    - #### trampoline

          public static <A,B> Trampoline<A,B> trampoline()

    - #### trampoline

          public static <A,B> Fn1<A,B> trampoline(Fn1<? super A,? extends RecursiveResult<A,B>> fn)

    - #### trampoline

          public static <A,B> B trampoline(Fn1<? super A,? extends RecursiveResult<A,B>> fn,
                                           A a)