On Thursday, 5 July 2018 at 09:47:32 UTC, Andre Pany wrote:
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é
roundRobin doesn't return RandomAccessRange => chunks doesn't
return range of RandomAccessRange => Error: no [] operator
overload
try this:
string content = roundRobin(timestamps, temperatures,
pressures)
.array
.chunks(3)
//.map!(c => c.array)
.map!(c => "%.10g,%.10g,%.10g".format(c[0],c[1],c[2]))
.join("\n");