Skip to content

Commit 37c4943

Browse files
committed
Convert P1 to use lambdas in core fj/data
1 parent 3d67791 commit 37c4943

10 files changed

Lines changed: 75 additions & 251 deletions

File tree

core/src/main/java/fj/data/LazyString.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,7 @@ public Stream<LazyString> split(final F<Character, Boolean> p) {
257257
final Stream<Character> findIt = s.dropWhile(p);
258258
final P2<Stream<Character>, Stream<Character>> ws = findIt.split(p);
259259
return findIt.isEmpty() ? Stream.<LazyString>nil()
260-
: Stream.cons(fromStream(ws._1()), new P1<Stream<LazyString>>() {
261-
public Stream<LazyString> _1() {
262-
return fromStream(ws._2()).split(p);
263-
}
264-
});
260+
: Stream.cons(fromStream(ws._1()), P.lazy(() -> fromStream(ws._2()).split(p)));
265261
}
266262

267263
public LazyString map(F<Character, Character> f) {

core/src/main/java/fj/data/List.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,7 @@ public final <B> B foldRight(final F2<A, B, B> f, final B b) {
704704
* @return A Trampoline containing the final result after the right-fold reduction.
705705
*/
706706
public final <B> Trampoline<B> foldRightC(final F2<A, B, B> f, final B b) {
707-
return Trampoline.suspend(new P1<Trampoline<B>>() {
708-
public Trampoline<B> _1() {
709-
return isEmpty() ? Trampoline.pure(b) : tail().foldRightC(f, b).map(F2Functions.f(f, head()));
710-
}
711-
});
707+
return Trampoline.suspend(P.lazy(() -> isEmpty() ? Trampoline.pure(b) : tail().foldRightC(f, b).map(F2Functions.f(f, head()))));
712708
}
713709

714710
/**

0 commit comments

Comments
 (0)