On Monday, 25 December 2017 at 21:11:08 UTC, aliak wrote:
On Monday, 25 December 2017 at 17:59:54 UTC, visitor wrote:
On Monday, 25 December 2017 at 15:03:08 UTC, aliak wrote:
On Monday, 25 December 2017 at 14:08:08 UTC, Mengu wrote:
I was kind of hoping for some magical D variadic alias
template on Tuple or something that will just deconstruct the
arguments in to tuple components.
i don't think it's better but :
https://run.dlang.io/is/2rgOzh
Heh, no it's probably not, but interesting! So it does work
with a static array. Is it that .array on a range is not able
to infer a size and hence produce a static array for the given
situation? Is this a D limitation, a logical one or maybe just
not implemented yet?
Cheers!
i don't know the reason, and would be glad to be unlighted :)
There is a Tuple constructor which takes a static array as a
param :
https://dlang.org/phobos/std_typecons.html#.Tuple.this.2
i needed to iterate with an index when building the static array
later, so i transformed the range (a.split(',').map!(to!int))
into a dynamic array, to do so.
one could use std.range enumerate() instead:
auto points = data.split(':')
.map!( a => a.split(',').map!(to!int) )
.map!( (a) {
int[2] staticArray;
foreach (i, el; a.enumerate())
staticArray[i] = el;
return staticArray;
} )
.map!Point;
Cheers