Partial Application =================== ```Example from 1 languages: JavaScript const addNumbers = (num1, num2) => num1 + num2 const add5 = num => addNumbers(10, num) ``` ```Example from 1 languages: C++ // http://www.cplusplus.com/reference/functional/bind/ // bind example #include <iostream> // std::cout #include <functional> // std::bind // a function: (also works with function object: std::divides<double> my_divide;) double my_divide (double x, double y) {return x/y;} struct MyPair { double a,b; double multiply() {return a*b;} }; int main () { using namespace std::placeholders; // adds visibility of _1, _2, _3,... // binding functions: auto fn_five = std::bind (my_divide,10,2); // returns 10/2 std::cout << fn_five() << '\n'; // 5 auto fn_half = std::bind (my_divide,_1,2); // returns x/2 std::cout << fn_half(10) << '\n'; // 5 auto fn_invert = std::bind (my_divide,_2,_1); // returns y/x std::cout << fn_invert(10,2) << '\n'; // 0.2 auto fn_rounding = std::bind<int> (my_divide,_1,_2); // returns int(x/y) std::cout << fn_rounding(10,3) << '\n'; // 3 MyPair ten_two {10,2}; // binding members: auto bound_member_fn = std::bind (&MyPair::multiply,_1); // returns x.multiply() std::cout << bound_member_fn(ten_two) << '\n'; // 20 auto bound_member_data = std::bind (&MyPair::a,ten_two); // returns ten_two.a std::cout << bound_member_data() << '\n'; // 10 return 0; } ``` ```Example from 1 languages: Scala def add(x: Int, y: Int) = {x+y}; add(1, _: Int) ``` ```Example from 1 languages: Clojure (defn fun-full [x y] (+ x y)) (fun-full 2 3) (def fun-half (partial fun-full 2)) (fun-half 3) ``` ```Example from 1 languages: Speedie main "hello world ${app.args[0]}" ``` * Languages *with* Partial Application include JavaScript, C++, Scala, Clojure, Speedie * View all concepts with or missing a *hasPartialApplication* measurement http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasPartialApplication&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22null%22%2C%22data%22%3A%22hasPartialApplication%22%2C%22origData%22%3A%22hasPartialApplication%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D missing http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasPartialApplication&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22!null%22%2C%22data%22%3A%22hasPartialApplication%22%2C%22origData%22%3A%22hasPartialApplication%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D with * Read more about Partial Application on the web: 1. https://en.wikipedia.org/wiki/Partial_application 1. Built with Scroll v178.2.3