Goal:
I want to execute a specific function for every permutation of an array. I don't need to save intermediate permutations.
Paraphrase:
I'm searching for a Javascript implementation of Heap's algorithm, that calls a function for each permutation
Taken from here: https://en.wikipedia.org/wiki/Heap%27s_algorithm
You could call it like