Exemple #1
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);
 }
Exemple #2
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);
 }