export function permutations<T>(x: T[], n: number=-1): T[][] {
  return [...ipermutations(x, n)];
}