Skip to content

Instantly share code, notes, and snippets.

@nivrith
Last active October 2, 2019 01:15
Show Gist options
  • Save nivrith/0827adafd4c2cb6deb8830844e11d4b1 to your computer and use it in GitHub Desktop.
Save nivrith/0827adafd4c2cb6deb8830844e11d4b1 to your computer and use it in GitHub Desktop.
Functional utils
const range = n => n > 0 ? [...range(n-1), n] : [];
const fact = n => n > 0 ? n * factorial(n-1) : 1;
const product = (...list) => list.flat(Infinity).reduce( (result, n) => result * n , 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment