本文整理了Java中fj.data.List.bind()
方法的一些代码示例,展示了List.bind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.bind()
方法的具体详情如下:
包路径:fj.data.List
类名称:List
方法名:bind
[英]Binds the given function across each element of this list with a final join.
[中]使用最终联接跨此列表的每个元素绑定给定函数。
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Performs function application within a list (applicative functor pattern).
*
* @param lf The list of functions to apply.
* @return A new list after applying the given list of functions through this list.
*/
public final <B> List<B> apply(final List<F<A, B>> lf) {
return lf.bind(this::map);
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Provides a first-class version of bind()
*
* @return The bind function for lists.
*/
public static <A, B> F<F<A, List<B>>, F<List<A>, List<B>>> bind_() {
return curry((f, as) -> as.bind(f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D> List<D> bind(final List<B> lb, final List<C> lc, final F<A, F<B, F<C, D>>> f) {
return lc.apply(bind(lb, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Performs a bind across each list element, but ignores the element value each time.
*
* @param bs The list to apply in the final join.
* @return A new list after the final join.
*/
public final <B> List<B> sequence(final List<B> bs) {
final F<A, List<B>> c = constant(bs);
return bind(c);
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given list with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given list.
* @return A new list after performing the map, then final join.
*/
public final <B, C> List<C> bind(final List<B> lb, final F2<A, B, C> f) {
return bind(lb, curry(f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Promotes the given function of arity-2 to a function on lists.
*
* @param f The function to promote to a function on lists.
* @return The given function, promoted to operate on lists.
*/
public static <A, B, C> F<List<A>, F<List<B>, List<C>>> liftM2(final F<A, F<B, C>> f) {
return curry((as, bs) -> as.bind(bs, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Joins the given list of lists using a bind operation.
*
* @param o The list of lists to join.
* @return A new list that is the join of the given lists.
*/
public static <A> List<A> join(final List<List<A>> o) {
final F<List<A>, List<A>> id = identity();
return o.bind(id);
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param ld A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D, E> List<E> bind(final List<B> lb, final List<C> lc, final List<D> ld,
final F<A, F<B, F<C, F<D, E>>>> f) {
return ld.apply(bind(lb, lc, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param ld A given list to bind the given function with.
* @param le A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D, E, F$> List<F$> bind(final List<B> lb, final List<C> lc, final List<D> ld, final List<E> le,
final F<A, F<B, F<C, F<D, F<E, F$>>>>> f) {
return le.apply(bind(lb, lc, ld, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param ld A given list to bind the given function with.
* @param le A given list to bind the given function with.
* @param lf A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D, E, F$, G> List<G> bind(final List<B> lb, final List<C> lc, final List<D> ld, final List<E> le,
final List<F$> lf, final F<A, F<B, F<C, F<D, F<E, F<F$, G>>>>>> f) {
return lf.apply(bind(lb, lc, ld, le, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param ld A given list to bind the given function with.
* @param le A given list to bind the given function with.
* @param lf A given list to bind the given function with.
* @param lg A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D, E, F$, G, H> List<H> bind(final List<B> lb, final List<C> lc, final List<D> ld, final List<E> le,
final List<F$> lf, final List<G> lg,
final F<A, F<B, F<C, F<D, F<E, F<F$, F<G, H>>>>>>> f) {
return lg.apply(bind(lb, lc, ld, le, lf, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Binds the given function across each element of this list and the given lists with a final
* join.
*
* @param lb A given list to bind the given function with.
* @param lc A given list to bind the given function with.
* @param ld A given list to bind the given function with.
* @param le A given list to bind the given function with.
* @param lf A given list to bind the given function with.
* @param lg A given list to bind the given function with.
* @param lh A given list to bind the given function with.
* @param f The function to apply to each element of this list and the given lists.
* @return A new list after performing the map, then final join.
*/
public final <B, C, D, E, F$, G, H, I> List<I> bind(final List<B> lb, final List<C> lc, final List<D> ld, final List<E> le,
final List<F$> lf, final List<G> lg, final List<H> lh,
final F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> f) {
return lh.apply(bind(lb, lc, ld, le, lf, lg, f));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Promotes this function to a function on non-empty lists.
*
* @return This function promoted to transform non-empty lists.
*/
public static <A, B, C> F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>> nelM(final F2<A, B, C> f) {
return (as, bs) -> NonEmptyList.fromList(as.toList().bind(bs.toList(), f)).some();
}
代码示例来源:origin: org.functionaljava/functionaljava
public final <B> List<List<B>> traverseList(final F<A, List<B>> f) {
return foldRight(
(a, acc) -> f.f(a).bind(b -> acc.map(bs -> bs.cons(b))),
single(List.nil()));
}
代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization
List<P2<Variable, Variable>> variableRenamings = subTermResults.bind(P3::_2);
List<P2<Variable, Constant>> variableConstantPairs = subTermResults.bind(P3::_3);
代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization
/**
* Merges a list of substitution into one and also returns a list of generated variable-to-variable equalities.
*
* See mergeVariableRenamings for further details.
*
*/
private static P2<Var2VarSubstitution, List<Function>> mergeSubstitutions(List<Var2VarSubstitution> substitutionsToMerge) {
/**
* Transforms the substitutions into list of variable-to-variable pairs and concatenates them.
*/
List<P2<Variable, Variable>> renamingPairs = substitutionsToMerge
// Transforms the map of the substitution in a list of pairs
.bind(substitution -> TreeMap.fromMutableMap(VARIABLE_ORD, substitution.getImmutableMap())
.toStream().toList());
/**
* Merges renaming variable-to-variable pairs into a substitution
* and retrieves generated variable-to-variable equalities.
*/
return mergeVariableRenamings(renamingPairs);
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Intersperses the given argument between each element of this list.
*
* @param a The separator to intersperse in this list.
* @return A list with the given separator interspersed.
*/
public final List<A> intersperse(final A a) {
return isEmpty() || tail().isEmpty() ?
this :
cons(head(), tail().bind(a2 -> list(a, a2)));
}
代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization
.bind(P3.<Term, List<P2<Variable, Variable>>, List<P2<Variable, Constant>>>__2());
List<P2<Variable,Constant>> varConstantPairs = atomResults.bind(
P3.<Term, List<P2<Variable, Variable>>, List<P2<Variable, Constant>>>__3());
List<Function> varConstantEqualities = generateVariableConstantEqualities(varConstantPairs);
代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization
.bind(PullOutEqLocalNormResult::getNonPushableAtoms);
.bind(PullOutEqLocalNormResult::getPushableBoolAtoms);
代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization
.bind(PullOutEqualityNormalizerImpl::generateVariableEqualities);
内容来源于网络,如有侵权,请联系作者删除!