Created
July 17, 2020 15:24
-
-
Save alandipert/19e214ee8d242fa88c835f44d325795e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeAt = (xs, i) => xs.filter((x, j) => j !== i); | |
const permute = xs => xs.length | |
? xs.flatMap((x, i) => permute(removeAt(xs, i)).map(ys => [x, ...ys])) | |
: [[]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment