Skip to content

Instantly share code, notes, and snippets.

@kutyel
Last active July 17, 2019 17:13
Show Gist options
  • Save kutyel/29ba74cd6bc4af77f63685d59139fd6b to your computer and use it in GitHub Desktop.
Save kutyel/29ba74cd6bc4af77f63685d59139fd6b to your computer and use it in GitHub Desktop.
Flavio's functional programming test
/*
* Implement the following classic FP functions using
* _only_ Array.prototype.{reduce|reduceRight}(). 🤓
*/
const filter = f => xs => xs
const map = f => xs => xs
const every = f => xs => xs
const some = f => xs => xs
const flatMap = f => xs => xs
const find = f => xs => xs
const findIndex = f => xs => xs
const reverse = xs => xs
/*
* Bonus! 👾
*/
const compose = (...fns) => args => args
const pipe = (...fns) => args => args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment