Trying to figure out how to generate slice permutations of specific length. Say in Python I can do:
>>> import itertools >>> l = list(itertools.permutations(range(1, 4), 2)) >>> print(l) [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
What would be the best way to achieve this in Go? I’ve been looking for a solution here which gives all permutations, but can’t figure out on how to specify length. Also, with larger slice this would eat up resources quickly.