Below are revisions for this snippet.

Generate all permutations of a list





Syndication

Revision Revison 1
This is snippet of code solves the interesting (and specialized) problem of generating all permutations of a list. I hope you like recursion. For exmaple:

permute( [0,1,2] )

would return

[[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]]