Class Occurrences<A>

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

public final class Occurrences<A> extends Object implements Fn1<Iterable<A>,Map<A,Long>>
Given an Iterable<A>, return a Map<A, Long> representing each unique element in the Iterable paired with its number of occurrences.
  • Field Details

    • INSTANCE

      private static final Occurrences<?> INSTANCE
  • Constructor Details

    • Occurrences

      private Occurrences()
  • Method Details

    • checkedApply

      public Map<A,Long> 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>,Map<A,Long>>
      Parameters:
      as - the argument
      Returns:
      the result of the function application
    • occurrences

      public static <A> Occurrences<A> occurrences()
    • occurrences

      public static <A> Map<A,Long> occurrences(Iterable<A> as)