I need to make a function that creates permutations recursively. Here we get [[1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 2, 2], [2, 1, 1], [2, 1, 2], [2, 2, 1], [2, 2, 2]] as all possible permutations of length 3, but I need to generalize it to length n. Anyone up for a challenge?

Anyone up for a challenge?