示例#1
0
 public default <A> Maybe<A> foldr1(final Function<A, Function<A, A>> fn, _<F, A> nestedA) {
     return foldr((A one) -> (Maybe<A> maybeTwo) ->
             maybeTwo.isJust()
                     ? Maybe.Just(fn.apply(one).apply(maybeTwo.get()))
                     : Maybe.Just(one),
             Maybe.<A>Nothing(), nestedA);
 }
示例#2
0
 public default <A> Maybe<A> foldl1(final Function<A, Function<A, A>> fn, _<F, A> nestedA) {
     return foldl((Maybe<A> maybeOne) -> (A two) ->
             maybeOne.isJust()
                     ? Maybe.Just(fn.apply(maybeOne.get()).apply(two))
                     : Maybe.Just(two),
             Maybe.<A>Nothing(), nestedA);
 }
示例#3
0
 public default <A, B> B foldMap1(Semigroup<B> sa, Function<A, B> fn, _<F, A> nestedA) {
     Maybe<B> result = foldMap(Maybe.<B>monoid(sa), a -> Maybe.Just(fn.apply(a)), nestedA);
     return result.getOrError("foldMap1 on mzero data structure");
 }