3 ms·
If you're like me and your first thought was "why can't we just use flatMap and mapMulti, the summary table in the linked article convincingly explains why: ht
by qsort 3y ago
If you're like me and your first thought was "why can't we just use flatMap and mapMulti, the summary table in the linked article convincingly explains why:
https://cr.openjdk.org/~vklang/Gatherers.html https://cr.openjdk.org/~vklang/Gatherers.html
- mjburgess 3y agoHow to implement flatMap(mapper) public final static <T,R> Gatherer<T, ?, R> flatMap(Function<? super T, ? extends Stream<R>> mapper){ return Gatherer.of( () -> (Void)null, (nothing, element, downstream) -> { try(Stream<? extends R> s = mapper.apply(element)) { return s == null || s.sequential().allMatch(downstream::flush); } }, (l,r) -> l, (nothing, downstream) -> {} ); } Better title: how scala won the war but lost every battle