Write some code to generate all permutations from an array of numbers.