On Saturday, 22 January 2022 at 01:33:16 UTC, Steven
Schveighoffer wrote:
That second `valuesPerRecord` is not used in the lambda, and
also it's not referring to the original element, it's the name
of a parameter in the lambda.
Are you sure this is doing what you want?
-Steve
It just worked, so i didn't think about it too much.. but it
seems to work either way.
And to be honest, the only part of it I understand, is the dice
part ;-)
In any case I changed it:
from: valuesPerRecord =>
to: i =>
// ----
void CreateDataFile(const(int) recordsNeeded, const(int)
valuesPerRecord, const(string) fname)
{
auto rnd = Random(unpredictableSeed);
auto file = File(fname, "w");
scope(exit) file.close;
Appender!string bigString = appender!string;
bigString.reserve(recordsNeeded);
const int iotaStartNum = 100_000_001;
foreach(i, id; iota(iotaStartNum, iotaStartNum +
recordsNeeded).enumerate)
{
bigString
~= id.to!string
~ ","
~ valuesPerRecord.iota.map!(i => rnd.dice(0.6,
1.4)).format!"%(%s,%)"
~ "\n";
}
file.write(bigString[]);
}
// ---