digitalmars.D.learn - Lazy Generation of Random Sequence
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/2) Apr 26 2016 How do I lazily generate a sequence of random instances of type
- =?UTF-8?B?Tm9yZGzDtnc=?= (6/8) Apr 26 2016 Ahh, I found it:
- Seb (5/14) Apr 26 2016 Btw if you do random generation at the moment, you should always
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/5) Apr 26 2016 So should I pass it by ref or const ref then?
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/7) Apr 26 2016 Doh. Const ref is of no use... just by ref then, right?
- Seb (5/10) Apr 26 2016 I guess both work fine, but this was just a warning for other
How do I lazily generate a sequence of random instances of type `T` as an `InputRange`?
Apr 26 2016
On Tuesday, 26 April 2016 at 10:31:22 UTC, Nordlöw wrote:How do I lazily generate a sequence of random instances of type `T` as an `InputRange`?Ahh, I found it: import std.range : generate, take; import std.random : uniform; auto randomSamples = generate!(() => uniform!Key).take(n); I should have guessed that...
Apr 26 2016
On Tuesday, 26 April 2016 at 10:50:27 UTC, Nordlöw wrote:On Tuesday, 26 April 2016 at 10:31:22 UTC, Nordlöw wrote:Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGen, see: http://dconf.org/2015/talks/wakeling.htmlHow do I lazily generate a sequence of random instances of type `T` as an `InputRange`?Ahh, I found it: import std.range : generate, take; import std.random : uniform; auto randomSamples = generate!(() => uniform!Key).take(n); I should have guessed that...
Apr 26 2016
On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote:Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGenSo should I pass it by ref or const ref then?
Apr 26 2016
On Tuesday, 26 April 2016 at 17:38:33 UTC, Nordlöw wrote:On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote:Doh. Const ref is of no use... just by ref then, right?Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGenSo should I pass it by ref or const ref then?
Apr 26 2016
On Tuesday, 26 April 2016 at 17:38:33 UTC, Nordlöw wrote:On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote:I guess both work fine, but this was just a warning for other case. The example that WebDrake mentioned on his slides can happen too easily - a reason why we should fix it (which is on my agenda).Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGenSo should I pass it by ref or const ref then?
Apr 26 2016