Re: please help me to reverse a function call order

2022-07-26 Thread Test123 via Digitalmars-d-learn
On Monday, 25 July 2022 at 21:43:37 UTC, Salih Dincer wrote: On Monday, 25 July 2022 at 04:23:16 UTC, test123 wrote: not match by: 1) the element is not repeat 2) the element is position related I got it now. So what good are such repetitive probabilities? Thanks... SDB@79 just try a stu

Re: please help me to reverse a function call order

2022-07-25 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 25 July 2022 at 04:23:16 UTC, test123 wrote: not match by: 1) the element is not repeat 2) the element is position related I got it now. So what good are such repetitive probabilities? Thanks... SDB@79

Re: please help me to reverse a function call order

2022-07-24 Thread test123 via Digitalmars-d-learn
On Sunday, 24 July 2022 at 15:49:51 UTC, Salih Dincer wrote: On Sunday, 24 July 2022 at 15:11:45 UTC, Salih Dincer wrote: ...But you know this classic recurisive function: The `permut()` function works with many types, for example `char`. Look at probability 40: 😀 ```d void main() { int t

Re: please help me to reverse a function call order

2022-07-24 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 24 July 2022 at 15:11:45 UTC, Salih Dincer wrote: ...But you know this classic recurisive function: The `permut()` function works with many types, for example `char`. Look at probability 40: 😀 ```d void main() { int totalCount; ['a', 'd', 'g', 'l', 'n'].permut(totalCount); t

Re: please help me to reverse a function call order

2022-07-24 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 24 July 2022 at 08:16:41 UTC, Test123 wrote: On Saturday, 23 July 2022 at 23:14:03 UTC, Salih Dincer wrote: On Saturday, 23 July 2022 at 22:50:55 UTC, Salih Dincer wrote: [...] I guess my code didn't list all possibilities either. Moreover, the m and n parameters will be swapped:

Re: please help me to reverse a function call order

2022-07-24 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 23:14:03 UTC, Salih Dincer wrote: On Saturday, 23 July 2022 at 22:50:55 UTC, Salih Dincer wrote: [...] I guess my code didn't list all possibilities either. Moreover, the m and n parameters will be swapped: [...] **PS.** * marked from version(c) in the above

Re: please help me to reverse a function call order

2022-07-23 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 23 July 2022 at 22:50:55 UTC, Salih Dincer wrote: **My code outputs:** ``` [0, 0, 0, 0, 0, 0, 0, 0]: 1 [0, 0, 0, 0, 0, 0, 0, 1]: 2 [0, 0, 0, 0, 0, 0, 1, 0]: 3 [0, 0, 0, 0, 0, 0, 2, 1]: 4 [0, 0, 0, 0, 0, 1, 1, 0]: 5 [0, 0, 0, 0, 0, 2, 0, 1]: 6 [0, 0, 0, 0, 0, 2, 1, 0]: 7 [0, 0, 0, 0,

Re: please help me to reverse a function call order

2022-07-23 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 23 July 2022 at 19:50:51 UTC, Test123 wrote: I has this function, it print all possible combinations. ```d void doRepetition(const int n, const int m){ // combination total number is m, element is repeatable. // ... } ``` `doRepetition(4, 3);` will print 0 0 0 1 0 2 1 1 1

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 20:00:06 UTC, rikki cattermole wrote: A bit more d-ified and uses foreach + foreach_reverse without allocating an array. [...] Your give the correct code, but wrong Output. Thanks again for the help.

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 20:00:06 UTC, rikki cattermole wrote: A bit more d-ified and uses foreach + foreach_reverse without allocating an array. [...] Thanks for the quick reply. I also get your results, it is not correct because the secends number is not matched. Not I look at you

Re: please help me to reverse a function call order

2022-07-23 Thread rikki cattermole via Digitalmars-d-learn
A bit more d-ified and uses foreach + foreach_reverse without allocating an array. ```d import std.stdio; void main() { doRepetition(4, 3); writeln("=="); doRepetitionReversed(4, 3); } void doRepetition(const int n, const int m) { // combination total number is m, elem

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 19:50:51 UTC, Test123 wrote: I has this function, it print all possible combinations. ```d void doRepetition(const int n, const int m){ // combination total number is m, element is repeatable. assert(n >= 1 && n < 10); assert(m >= 1 && m < 10); enum