Skip to content

Instantly share code, notes, and snippets.

@simonqian
Created December 18, 2017 08:15
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 simonqian/63a6400b073cf5d01db7563a6c2464dd to your computer and use it in GitHub Desktop.
Save simonqian/63a6400b073cf5d01db7563a6c2464dd to your computer and use it in GitHub Desktop.
function cartesian() {
return _.reduce(arguments, function (a, b) {
return _.flatten(_.map(a, function (x) {
return _.map(b, function (y) {
return x.concat([y])
})
}), true)
}, [[]])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment