Re: Array permutations

2021-09-16 Thread Elmar via Digitalmars-d-learn
I also should discourage its current form with large `tupleSize`s. The computation is in O(exp(values.length)). Instead of `~=` I would suggest an `std.array.appender` of arrays instead of an 2D-array for the `choices`, if the `choices` become large. Most efficient is a preallocated array

Re: Array permutations

2021-09-16 Thread Elmar via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values

Re: Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
On Saturday, 11 September 2021 at 23:04:29 UTC, Vino wrote: On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: [...] Hi, Thank you very much, let me try to explain the actual requirement, the actual requirement is to find all the permutations of a given array, I modified

Re: Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2),

Re: Array permutations

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: auto pairs = list.cartesianProduct(list.drop(1)) This `drop` isn't necessary.

Re: Array permutations

2021-09-11 Thread Dukc via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values "1,3],[1,4],[1,5],[2,4],[2,5],[3,5]" ```d

Re: Array permutations

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values

Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values "1,3],[1,4],[1,5],[2,4],[2,5],[3,5]" auto list[] = [1,2,3,4,5] Required output