On 01/25/2012 12:28 PM, C wrote:
auto chunk = new ubyte[1024];
foreach(ref x; chunk) x = uniform![](ubyte.min, ubyte.max);
Thank you all for your replies.
@ Timon, I have two questions:
1) How come you can omit parentheses for uniform's parameter, shouldn't it be
uniform!([])(...) ?
If
C:
I want to fill a ubyte array with random data.
In D ubytes are not char, they are two different types. So if you want ubytes,
then use ubytes:
uniform!([])(ubyte.min, ubyte.max)
Regarding your error, a reduced test case:
import std.random: uniform;
void main() {
On 01/25/2012 04:50 AM, bearophile wrote:
C:
I want to fill a ubyte array with random data.
In D ubytes are not char, they are two different types. So if you want ubytes,
then use ubytes:
uniform!([])(ubyte.min, ubyte.max)
Regarding your error, a reduced test case:
import std.random:
', prng));
Error (at runtime):
object.Exception@c:\dmd2\windows\bin\..\..\src\phobos\std\random.d(971):
std.random.uniform(): invalid bounding interval [ , �]
423C50
423AC7
404EA8
404EEC
404AE3
4A6109
Also I lost the URL for this forum, all I see is this nasty PHP
1) How come you can omit parentheses for uniform's
parameter, shouldn't it be
uniform!([])(...) ?
I think I can answer this.
With ! already being used, it already knows it's a template and is separating
your argument. Being as you only have 1 argument, it's allowed. That's why you
can