Class MinBy<A,B extends java.lang.Comparable<B>>
- java.lang.Object
-
- com.jnape.palatable.lambda.semigroup.builtin.MinBy<A,B>
-
- Type Parameters:
A
- the value typeB
- the mapped comparison type
- All Implemented Interfaces:
Fn1<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>>
,Fn2<Fn1<? super A,? extends B>,A,Fn1<A,A>>
,Fn3<Fn1<? super A,? extends B>,A,A,A>
,SemigroupFactory<Fn1<? super A,? extends B>,A>
,Applicative<Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
,Cartesian<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Cocartesian<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Contravariant<Fn1<? super A,? extends B>,Profunctor<?,Fn1<A,Fn1<A,A>>,Fn1<?,?>>>
,Functor<Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
,Profunctor<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Monad<Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
,MonadReader<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
,MonadRec<Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
,MonadWriter<Fn1<? super A,? extends B>,Fn1<A,Fn1<A,A>>,Fn1<Fn1<? super A,? extends B>,?>>
public final class MinBy<A,B extends java.lang.Comparable<B>> extends java.lang.Object implements SemigroupFactory<Fn1<? super A,? extends B>,A>
Given a mapping function from some typeA
to someComparable
typeB
, produce aSemigroup
overA
that chooses between two valuesx
andy
via the following rules:- If
x
is strictly greater thany
in terms ofB
, returny
- Otherwise, return
x
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MinBy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Semigroup<A>
checkedApply(Fn1<? super A,? extends B> compareFn)
Invoke this function with the given argument, potentially throwing anyThrowable
.static <A,B extends java.lang.Comparable<B>>
MinBy<A,B>minBy()
static <A,B extends java.lang.Comparable<B>>
Semigroup<A>minBy(Fn1<? super A,? extends B> compareFn)
static <A,B extends java.lang.Comparable<B>>
Fn1<A,A>minBy(Fn1<? super A,? extends B> compareFn, A x)
static <A,B extends java.lang.Comparable<B>>
AminBy(Fn1<? super A,? extends B> compareFn, A x, A y)
-
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.Fn1
andThen, carry, cartesian, censor, choose, cocartesian, diMap, diMapR, discardL, flatMap, fmap, lazyZip, listens, local, pure, self, thunk, toFunction, trampolineM, zip, zip
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn2
toBiFunction
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn3
apply, apply, checkedApply, compose, contraMap, diMapL, discardR, flip, uncurry, widen
-
Methods inherited from interface com.jnape.palatable.lambda.functions.specialized.SemigroupFactory
apply, checkedApply
-
-
-
-
Field Detail
-
INSTANCE
private static final MinBy<?,?> INSTANCE
-
-
Method Detail
-
checkedApply
public Semigroup<A> checkedApply(Fn1<? super A,? extends B> compareFn)
Description copied from interface:Fn2
Invoke this function with the given argument, potentially throwing anyThrowable
.- Specified by:
checkedApply
in interfaceFn1<A,B extends java.lang.Comparable<B>>
- Specified by:
checkedApply
in interfaceFn2<Fn1<? super A,? extends B extends java.lang.Comparable<B>>,A,Fn1<A,A>>
- Specified by:
checkedApply
in interfaceSemigroupFactory<A,B extends java.lang.Comparable<B>>
- Parameters:
compareFn
- the argument- Returns:
- the result of the function application
-
minBy
public static <A,B extends java.lang.Comparable<B>> MinBy<A,B> minBy()
-
minBy
public static <A,B extends java.lang.Comparable<B>> Semigroup<A> minBy(Fn1<? super A,? extends B> compareFn)
-
minBy
public static <A,B extends java.lang.Comparable<B>> Fn1<A,A> minBy(Fn1<? super A,? extends B> compareFn, A x)
-
minBy
public static <A,B extends java.lang.Comparable<B>> A minBy(Fn1<? super A,? extends B> compareFn, A x, A y)
-
-