Class Last<A>

java.lang.Object
com.jnape.palatable.lambda.functions.builtin.fn1.Last<A>
Type Parameters:
A - the Iterable element type
All Implemented Interfaces:
Fn1<Iterable<A>, Maybe<A>>, Applicative<Maybe<A>, Fn1<Iterable<A>, ?>>, Cartesian<Iterable<A>, Maybe<A>, Fn1<?,?>>, Cocartesian<Iterable<A>, Maybe<A>, Fn1<?,?>>, Contravariant<Iterable<A>, Profunctor<?,Maybe<A>,Fn1<?,?>>>, Functor<Maybe<A>, Fn1<Iterable<A>, ?>>, Profunctor<Iterable<A>, Maybe<A>, Fn1<?,?>>, Monad<Maybe<A>, Fn1<Iterable<A>, ?>>, MonadReader<Iterable<A>, Maybe<A>, Fn1<Iterable<A>, ?>>, MonadRec<Maybe<A>, Fn1<Iterable<A>, ?>>, MonadWriter<Iterable<A>, Maybe<A>, Fn1<Iterable<A>, ?>>

public final class Last<A> extends Object implements Fn1<Iterable<A>, Maybe<A>>
Retrieve the last element of an Iterable, wrapped in a Maybe. If the Iterable is empty, the result is Maybe.nothing().
  • Field Details

    • INSTANCE

      private static final Last<?> INSTANCE
  • Constructor Details

    • Last

      private Last()
  • Method Details

    • checkedApply

      public Maybe<A> checkedApply(Iterable<A> as)
      Description copied from interface: Fn1
      Invoke this function with the given argument, potentially throwing any Throwable.
      Specified by:
      checkedApply in interface Fn1<Iterable<A>, Maybe<A>>
      Parameters:
      as - the argument
      Returns:
      the result of the function application
    • last

      public static <A> Last<A> last()
    • last

      public static <A> Maybe<A> last(Iterable<A> as)