ranges.chunks and map! does not work

Andre Pany andre at s-e-a-p.de
Thu Jul 5 09:47:32 UTC 2018


Hi,

the purpose of this code is to generate CSV based on 3 double 
arrays.
I wonder why map cannot directly use the result of the chunks 
function.

import std.experimental.all;

void main()
{
     double[] timestamps = [1.1];
     double[] temperatures = [2.2];
     double[] pressures = [3.3];

     string content = roundRobin(timestamps, temperatures, 
pressures)
         .chunks(3)
         //.map!(c => c.array)
         .map!(c => "%.10g,%.10g,%.10g".format(c[0],c[1],c[2]))
         .join("\n");

     writeln(content);
}

The exact error message is (this line is 3 times repeated):
app1.d(12): Error: no [] operator overload for type Take!(Result)
app1.d(12): Error: no [] operator overload for type Take!(Result)
app1.d(12): Error: no [] operator overload for type Take!(Result)
C:\SAPDevelop\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(499):        instantiated from here: MapResult!(__lambda1, Chunks!(Result))
app1.d(12):        instantiated from here: map!(Chunks!(Result))

Is it correct that I need to call ".map!(c => c.array)"?

Kind regards
André



More information about the Digitalmars-d-learn mailing list