Re: replace switch for mapping

2017-09-05 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:54:27 UTC, EntangledQuanta wrote: On Monday, 4 September 2017 at 09:23:24 UTC, Andrea Fontana wrote: On Thursday, 31 August 2017 at 23:17:52 UTC, EntangledQuanta wrote: Generally one has to use a switch to map dynamic components. Given a set X and Y one can

Re: replace switch for mapping

2017-09-04 Thread EntangledQuanta via Digitalmars-d-learn
On Monday, 4 September 2017 at 09:23:24 UTC, Andrea Fontana wrote: On Thursday, 31 August 2017 at 23:17:52 UTC, EntangledQuanta wrote: Generally one has to use a switch to map dynamic components. Given a set X and Y one can form a switch to map X to Y: [...] Does this work for you?

Re: replace switch for mapping

2017-09-04 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 31 August 2017 at 23:17:52 UTC, EntangledQuanta wrote: Generally one has to use a switch to map dynamic components. Given a set X and Y one can form a switch to map X to Y: [...] Does this work for you? https://dpaste.dzfl.pl/e2669b595539 Andrea

Re: replace switch for mapping

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
I came up with a library solution that isn't pretty ;/ I offer it up to the gods, but being gods, they probably don't care. template EnumMapper(alias func, string[] args, eT...) { import std.meta, std.typecons, std.traits, std.string, std.algorithm, std.array, std.conv; private

replace switch for mapping

2017-08-31 Thread EntangledQuanta via Digitalmars-d-learn
Generally one has to use a switch to map dynamic components. Given a set X and Y one can form a switch to map X to Y: switch(X) { case x1 : y1; break; case x1 : y1; } Is there any easier way to do this where one simply specifies the set's rather than having to create a switch