On Wednesday, 9 March 2016 at 07:30:31 UTC, Edwin van Leeuwen
wrote:
On Sunday, 6 March 2016 at 17:35:38 UTC, Seb wrote:
[...]
In ggplotd I often use named tuples as and "anonymoous" struct:
Tuple!(double,"x")( 0.0 )
I also added a merge function that will return a tuple
containing merged named tuples:
Tuple!(double,"x",string,"colour")(-1,
"black").merge(Tuple!(double,"x")(0.0))
returns:
Tuple!(double,"x",string,"colour")(0, "black");
As an aside the merge function also works with structs so you
can do the following:
struct Point
{
double x;
double y;
}
Tuple!(double,"x",string,"colour")(-1,
"black").merge(Point(1,2))
returns:
Tuple!(double,"x",double,"y",string,"colour")(1, 2, "black");
It works reasonably well, except that the tuples require a lot
of typing.
slightly tangentially, you might be interested in this:
https://github.com/D-Programming-Language/phobos/pull/4043