Re: Issue Turning Template into Variadic Template

2016-03-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 31, 2016 at 07:43:38PM +0200, ag0aep6g via Digitalmars-d-learn wrote: > On 30.03.2016 20:12, jmh530 wrote: > >I wrote a version of cartesianProduct that will return the cartesian > >product when the some of the types are not ranges. The original code > >is below. > > > >My issue is

Re: Issue Turning Template into Variadic Template

2016-03-31 Thread ag0aep6g via Digitalmars-d-learn
On 30.03.2016 20:12, jmh530 wrote: I wrote a version of cartesianProduct that will return the cartesian product when the some of the types are not ranges. The original code is below. My issue is that I can't figure out how to turn it into a variadic template. The latest thing I tried is: auto

Re: Issue Turning Template into Variadic Template

2016-03-31 Thread jmh530 via Digitalmars-d-learn
On Thursday, 31 March 2016 at 10:27:41 UTC, Artur Skawina wrote: auto mixedCartesianProduct(T...)(T x) { import std.range, std.algorithm : cartesianProduct; return mixin(`cartesianProduct(`~iota(T.length).map!`"conditionalOnly(x["~text(a)~"])"`().join(",")~`)`); }

Re: Issue Turning Template into Variadic Template

2016-03-31 Thread Artur Skawina via Digitalmars-d-learn
On 03/30/16 20:12, jmh530 via Digitalmars-d-learn wrote: > I wrote a version of cartesianProduct that will return the cartesian product > when the some of the types are not ranges. The original code is below. > > My issue is that I can't figure out how to turn it into a variadic template. >

Re: Issue Turning Template into Variadic Template

2016-03-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 30, 2016 at 08:43:03PM +, jmh530 via Digitalmars-d-learn wrote: > On Wednesday, 30 March 2016 at 18:56:29 UTC, H. S. Teoh wrote: > > > >Does this do what you want? > > > > Okay, I've looked at this a bit more thoroughly and it works perfectly > (perhaps with a better name put in

Re: Issue Turning Template into Variadic Template

2016-03-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 18:56:29 UTC, H. S. Teoh wrote: Does this do what you want? Okay, I've looked at this a bit more thoroughly and it works perfectly (perhaps with a better name put in phobos?). If I'm understanding this correctly, the ImplType creates the correct type

Re: Issue Turning Template into Variadic Template

2016-03-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 18:56:29 UTC, H. S. Teoh wrote: Does this do what you want? I think it does. That's an approach I would not have thought of. I do not really know much about AliasSeq.

Re: Issue Turning Template into Variadic Template

2016-03-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 30, 2016 at 06:12:40PM +, jmh530 via Digitalmars-d-learn wrote: > I wrote a version of cartesianProduct that will return the cartesian > product when the some of the types are not ranges. The original code > is below. > > My issue is that I can't figure out how to turn it into a

Issue Turning Template into Variadic Template

2016-03-30 Thread jmh530 via Digitalmars-d-learn
I wrote a version of cartesianProduct that will return the cartesian product when the some of the types are not ranges. The original code is below. My issue is that I can't figure out how to turn it into a variadic template. The latest thing I tried is: auto mixedCartesianProduct(T...)(T x)