static L allPermutations_arrays(L l) { int n = factorial(l(l)); L out = new L(n); allPermutations_arrays_impl(cloneList(l), l(l), out); ret out; } static void allPermutations_arrays_impl(L l, int n, L out) { if (n <= 1) { ping(); out.add(toObjectArray(l)); } else for(int i = 0; i < n; i++) { allPermutations_arrays_impl(l, n-1, out); swapElements(l, n % 2 == 0 ? i : 0, n-1); } }