Re: staticMap but with two arguments

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 12:45, John Chapman wrote: > On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: >> I could not figure out eliminating the hard-coded 4. Can we introspect >> the parameter list of a template like 'fun' in the example? If we >> could, then we could get 4 that way. > > Thank y

Re: staticMap but with two arguments

2023-02-09 Thread John Chapman via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: I could not figure out eliminating the hard-coded 4. Can we introspect the parameter list of a template like 'fun' in the example? If we could, then we could get 4 that way. Thank you for this. I don't mind hard-coding the N argu

Re: staticMap but with two arguments

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 12:04, John Chapman wrote: > rather than write it manually for each N? import std.meta : AliasSeq; template pickArgs(size_t totalElements, size_t argsPerElement, size_t whichElement, args...) { alias pickArgs = AliasSeq!();

Re: staticMap but with two arguments

2023-02-08 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: So I've got this implementation, but wonder if I can generalise the arg splitting portion rather than write it manually for each N? ```d template staticMapN(size_t N

Re: staticMap but with two arguments

2023-02-06 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: Thanks Ali, that's perfect. I thought of splitting the args in half a few hours later but hadn't got around to trying it.

Re: staticMap but with two arguments

2023-02-06 Thread Ali Çehreli via Digitalmars-d-learn
On 2/5/23 17:20, John Chapman wrote: > staticMap's "fun" can only be > instantiated with a single argument, while I need it to work with two. I adapted staticMap's implementation to two sets of arguments: import std.meta : AliasSeq; // The first half of 'args' is the "first arguments" and // t