Skip to content

Instantly share code, notes, and snippets.

@cajar1988
Created October 30, 2015 19:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cajar1988/f70c724b273f7eac6a1d to your computer and use it in GitHub Desktop.
//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