Last active
February 11, 2018 22:20
-
-
Save IsTheJack/6fa883c7d616d3e9e28fc085165355ed to your computer and use it in GitHub Desktop.
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
// implementando operador de composição (f1 º f2)(value) | |
const compose2 = (fn1, fn2) => value => fn1(fn2(value)); | |
// Criando duas funções puras | |
const increment = (n) => n + 1; | |
const double = (n) => n * 2; | |
// Compondo duas funções puras. | |
const incrementedDouble = compose2(increment, double); | |
// Output | |
incrementedDouble(2); // -> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment