Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- StreamF.of(1, 2, 3, 4)
- .apply(Main::up)
- .add(Stream::flatMap, Function.identity())
- .s
- .forEach(System.out::println);
- }
- public static <T> Stream<Stream<T>> up(Stream<T> s) {
- return Stream.of(s);
- }
- record StreamF<T>(Stream<T> s) {
- @SafeVarargs
- static <T> StreamF<T> of(T... t) {
- return new StreamF<>(Stream.of(t));
- }
- public <V> StreamF<V> add(BiFunction<Stream<T>, Function<T, Stream<V>>, Stream<V>> f, Function<T, Stream<V>> c) {
- return new StreamF<>(f.apply(s, c));
- }
- public <V> StreamF<V> apply(Function<? super Stream<T>, ? extends Stream<V>> c) {
- return new StreamF<>(c.apply(s));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement