Skip to content

Instantly share code, notes, and snippets.

@apnerve
Created January 11, 2022 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apnerve/12a89f712e6fe2c95849166150435444 to your computer and use it in GitHub Desktop.
Save apnerve/12a89f712e6fe2c95849166150435444 to your computer and use it in GitHub Desktop.
function average(x, n=1) {
return function(y) {
if(y) {
n++
return average(x+y, n)
}
return x/n
}
}
// const average = (x, n = 1) => y => y? average(x+y,++n): x/n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment