Instantly share code, notes, and snippets.

@cajar1988 /curried.java Secret
Created Oct 30, 2015

Embed
What would you like to do?
//pure JDK8
BiFunction<String, String, Integer> len_jdk8 = (s, s2) -> (s + s2).length();
//javaslang
Function2<String, String, Integer> len = (s, s2) -> (s + s2).length();
//dzieki javaslang mozemy uzyc funkcji, nawet jesli brakuje argumentow, i beda one przekazane pozniej
//wariant pierwszy
Function1<String, Function1<String, Integer>> lenCurried = len.curried();
Function1<String, Integer> lenCurriedExecuted = lenCurried.apply("s1");
Integer lenCurriedResult = lenCurriedExecuted.apply("s2");
//wariant drugi
Function1<String, Integer> lenWithFirstArg = len.apply("s1");
Integer result = lenWithFirstArg.apply("s2");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment