map question
Ali Çehreli
acehreli at yahoo.com
Sat Jan 22 22:49:38 UTC 2022
On 1/22/22 11:32, forkit wrote:
> trying to make sense of the below:
The generate() solution shown by Stanislav Blinov is suitable here.
> auto rnd = Random(unpredictableSeed);
Somebody else mentioned this before but none of the programs we've seen
so far seemed to need a special random number generator. So, the default
one, which is already randomized, would suffice. Just drop the line above.
> // ok - using 'e =>' makes sense
> writeln(howManyTimes.iota.map!(e => rnd.dice(0.6,
> 1.4)).format!"%(%s,%)");
When there is a syntactic need for a variable but that variable is not
used, the idiomatic way of naming that variable is '_':
howManyTimes.iota.map!(_ => dice(0.6, 1.4))
(Note: I did not write rnd.dice.)
Ali
More information about the Digitalmars-d-learn
mailing list