Skip to content

Commit 2d6a8dd

Browse files
committed
Reviewed use of new P1 to use P.lazy
1 parent 701ae46 commit 2d6a8dd

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

core/src/main/java/fj/control/parallel/Callables.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,13 @@ public static <A> F<List<Callable<A>>, Callable<List<A>>> sequence_() {
166166
* @return An optional value that yields the value in the Callable, or None if the Callable fails.
167167
*/
168168
public static <A> P1<Option<A>> option(final Callable<A> a) {
169-
return new P1<Option<A>>() {
170-
@SuppressWarnings({"UnusedCatchParameter"})
171-
public Option<A> _1() {
169+
return P.lazy(() -> {
172170
try {
173171
return some(a.call());
174172
} catch (Exception e) {
175173
return none();
176174
}
177-
}
178-
};
175+
});
179176
}
180177

181178
/**

core/src/main/java/fj/data/vector/V8.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,7 @@ public NonEmptyList<A> toNonEmptyList() {
228228
* @return a stream of the elements of this vector.
229229
*/
230230
public Stream<A> toStream() {
231-
return Stream.cons(head._1(), new P1<Stream<A>>() {
232-
F0<Stream<A>> f = 100;
233-
public Stream<A> _1() {
234-
return tail.toStream();
235-
}
236-
});
231+
return Stream.cons(head._1(), P.lazy(() -> tail.toStream()));
237232
}
238233

239234
/**

0 commit comments

Comments
 (0)