Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save anirudh-eka/a599e8540b0ebc2598d7ab81ea50c74b to your computer and use it in GitHub Desktop.

Select an option

Save anirudh-eka/a599e8540b0ebc2598d7ab81ea50c74b to your computer and use it in GitHub Desktop.
const mapAdd1Reducer = (a, x) => {
const transformed = x + 1;
return a.concat(transformed)
}
const filterGreaterThan2Transducer = reducer => (a, x) => {
if(x > 2) {
return reducer(a, x)
} else {
return a;
}
}
[1, 2, 3].reduce(filterGreaterThan2Transducer(mapAdd1Reducer), []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment