-
Notifications
You must be signed in to change notification settings - Fork 51
cyclops functions : Partial Application
johnmcclean-aol edited this page Nov 21, 2016
·
3 revisions
Cyclops has merged with simple-react. Please update your bookmarks (stars :) ) to https://github.com/aol/cyclops-react

We can also create partially applied functions. These are functions were the some of the input values to a function are provided up front, but not all. It converts, for example, a function that takes 3 input parameters, into a function that takes only 1. E.g.
TriFunction<String, String, String, String> concat = (a, b, c) -> a + b + c;
We can create a partially applied concatanator that will concat a supplied parameter to “hello” and “world” e.g.
Function<String, String> pa = PartialApplicator.partial3(“Hello” ,“World”, concat);
Using our new concatonator function (pa) with “!!!” should give use “Hello World!!!”
assertThat(concatStrings.apply(“!!!”), equalTo(“Hello World!!!”));