On Sunday, 23 January 2022 at 09:38:57 UTC, Siarhei Siamashka
wrote:
On Sunday, 23 January 2022 at 09:08:46 UTC, Stanislav Blinov
wrote:
Using `iota` here incurs additional computation and argument
copies that are actually never used, i.e. wasted work. So I'd
say go with `generate`, as that see
On Sunday, 23 January 2022 at 09:08:46 UTC, Stanislav Blinov
wrote:
Using `iota` here incurs additional computation and argument
copies that are actually never used, i.e. wasted work. So I'd
say go with `generate`, as that seems the intent.
Isn't this normally a compiler's job to eliminate all
On Saturday, 22 January 2022 at 23:54:27 UTC, forkit wrote:
On Saturday, 22 January 2022 at 19:55:43 UTC, Stanislav Blinov
wrote:
thanks for the explanation. That really helped :-)
writeln( generate!(() => dice(0.6, 1.4)).take(howManyTimes) );
[1, 1, 1, 1, 0]
(or after reading Ali's respons
On Saturday, 22 January 2022 at 19:55:43 UTC, Stanislav Blinov
wrote:
thanks for the explanation. That really helped :-)
writeln( generate!(() => dice(0.6, 1.4)).take(howManyTimes) );
[1, 1, 1, 1, 0]
(or after reading Ali's response - getting rid of rnd, and using
_ )
writeln( howManyTime
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 n
7; - but isn't this effectively the
same as above line?
//writeln(howManyTimes.iota.map!(5 => rnd.dice(0.6,
1.4)).format!"%(%s,%)");
}
// ---
No, it's not the same. 'Tis not really a "map question", looks
more like a question about
https://dlang.org/s
trying to make sense of the below:
// ---
module test;
import std;
void main()
{
auto rnd = Random(unpredictableSeed);
int howManyTimes = 5;
// ok - using 'e =>' makes sense
writeln(howManyTimes.iota.map!(e => rnd.dice(0.6,
1.4)).format!"%(%s,%)");
// ok - though using