This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.function.Function; | |
| import static java.lang.String.format; | |
| class SamplePartialApplication { | |
| public static void main(String[] args) { | |
| Fx2<Integer, Integer, Integer> add = (x, y) -> x + y; | |
| System.out.println(format("Fully applied function of 2 arity result: %s", add.apply(2, 3))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.math.BigDecimal; | |
| import java.util.function.Function; | |
| import static java.lang.String.format; | |
| class ComposingFunctions { | |
| public static void main(String[] args) { | |
| Function<BigDecimal, Integer> asInteger = a -> a.intValue(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.function.Function; | |
| import static java.lang.String.format; | |
| class Scratch { | |
| public static void main(String[] args) { | |
| //instantiate as an object | |
| Function<Integer, String> stringifyInteger = stringifyInteger(); | |
| System.out.println(format("Output is %s", stringifyInteger.apply(3))); |
NewerOlder