fork(2) download
  1. import java.util.*;
  2. import java.util.function.*;
  3. import java.util.stream.*;
  4.  
  5. class Ideone {
  6. public static final Function<List<IntUnaryOperator>, UnaryOperator<List<Integer>>> mapper =
  7. opList -> argList -> argList.stream()
  8. .map(i -> {
  9. List<Integer> resList = new ArrayList<>();
  10. for (IntUnaryOperator op : opList) {
  11. i = op.applyAsInt(i);
  12. resList.add(i);
  13. }
  14. return resList;
  15. })
  16. .flatMap(List::stream)
  17. .collect(Collectors.toList());
  18.  
  19. public static void main(String[] args) {
  20. List<Integer> list = mapper.apply(List.of(x -> x, x -> x + 1, x -> x * x)).apply(List.of(1, 2));
  21. System.out.println(list);
  22. }
  23. }
Success #stdin #stdout 0.08s 34404KB
stdin
Standard input is empty
stdout
[1, 2, 4, 2, 3, 9]