Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,20 @@
|
|||
import module java.base;
|
||||
|
||||
public final class HigherOrderFunctions {
|
||||
|
||||
public static void main() {
|
||||
Function<Integer, Integer> square = n -> n * n;
|
||||
|
||||
Function<Integer, Integer> cube = n -> n * n * n;
|
||||
|
||||
BiConsumer<String, Function<Integer, Integer>> demonstration = (s, f) -> {
|
||||
IO.print(s + " => ");
|
||||
IntStream.rangeClosed(1, 9).forEach( i -> IO.print("%4s".formatted(f.apply(i))) );
|
||||
IO.println();
|
||||
};
|
||||
|
||||
demonstration.accept("Squares", square);
|
||||
demonstration.accept("Cubes ", cube);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue