Skip to content

Instantly share code, notes, and snippets.

@asvny
Created August 22, 2016 15:01
Show Gist options
  • Save asvny/5c16a3c33604d3fa74ac5ee2f80c497d to your computer and use it in GitHub Desktop.
Save asvny/5c16a3c33604d3fa74ac5ee2f80c497d to your computer and use it in GitHub Desktop.
functional flatten
const flatten = xs => {
let next = (acc, xs) => xs.reduce((x, y) => Array.isArray(y)
? next(x, y)
: (x[x.length] = y, x)
, acc);
return next([], xs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment