static <A> L<O[]> allPermutations_arrays(L<A> l) { int n = factorial(l(l)); L<O[]> out = new L(n); allPermutations_arrays_impl(cloneList(l), l(l), out); ret out; } static <A> void allPermutations_arrays_impl(L<A> l, int n, L<O[]> 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); } }
Began life as a copy of #1010320
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010344 |
Snippet name: | allPermutations_arrays - return all permutations of a list |
Eternal ID of this version: | #1010344/5 |
Text MD5: | 444c7af8dc2df0fe1719603048a7c80b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-09-12 02:39:40 |
Source code size: | 455 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 416 / 463 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |