Last active
August 6, 2018 07:44
-
-
Save anirudh-eka/9c8efe1e73251625b16b2e9714acf721 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
| const mapping = mapLogic => reducer => (a, x) => { | |
| const transformed = mapLogic(x); | |
| return reducer(a, transformed) | |
| } | |
| const filtering = filterLogic => reducer => (a, x) => { | |
| if(filterLogic(x)) { | |
| return reducer(a, x) | |
| } else { | |
| return a; | |
| } | |
| } | |
| const trance = compose([filtering(x => x > 2), mapping(x => x + 1)]); | |
| [1, 2, 3].reduce(trance((a, x) => a.concat(x)), []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment