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

please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
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 N = 10; ubyte[10] a; void inc(int index, int r, int

Re: Expanding CTFE code during compilation

2022-07-23 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 23 July 2022 at 00:56:39 UTC, Steven Schveighoffer wrote: On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {   

Re: OK to do bit-packing with GC pointers?

2022-07-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 23 July 2022 at 08:32:12 UTC, Ola Fosheim Grøstad wrote: Also `char*` can't work as char cannot contain pointers. I guess you would need to use `void*`. Well, that is wrong for the standard collection where the typing is dynamic (based on allocation not on type system). Then any

Re: OK to do bit-packing with GC pointers?

2022-07-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 23 July 2022 at 00:55:14 UTC, Steven Schveighoffer wrote: Probably. Though like I said, I doubt it matters. Maybe someone with more type theory or GC knowledge knows whether it should be OK or not. Has nothing to do with type theory, only about GC implementation. But his object h