## digitalmars.D.learn - Re: Generate array of random values

Jesse Phillips <jessekphillips+D gmail.com> writes:
```Andrej Mitrovic Wrote:

I'm currently using this:

import std.algorithm;
import std.array;
import std.random;
import std.range;

void main()
{
auto arr2 = array(map!( (int){ return uniform(0, 1024); })(iota(0, 1024)));
}

Is there a simpler way to do get an array of random values?

Untested:

auto arr = new int[1024];
fill(arr, uniform(0, 1024));
```
Aug 01 2011
```On 8/2/11 3:40 AM, Jesse Phillips wrote:
Andrej Mitrovic Wrote:
Is there a simpler way to do get an array of random values?

Untested:

auto arr = new int[1024];
fill(arr, uniform(0, 1024));

This does a great job of creating an array containing the same random
value 1024 times. ;)

David
```
Aug 01 2011
Jesse Phillips <jessekphillips+d gmail.com> writes:
```On Tue, 02 Aug 2011 03:48:03 +0200, David Nadlinger wrote:

On 8/2/11 3:40 AM, Jesse Phillips wrote:
Andrej Mitrovic Wrote:
Is there a simpler way to do get an array of random values?

Untested:

auto arr = new int[1024];
fill(arr, uniform(0, 1024));

This does a great job of creating an array containing the same random
value 1024 times. ;)

David

Fine, let me provide a tested one:

import std.algorithm;
import std.array;
import std.random;
import std.range;

void main()
{
auto arr = new int[1024];
fill(arr, randomCover(iota(0,1024), rndGen));
}

Knew I had done something with fill before.
```
Aug 01 2011
```On 8/2/11 6:42 AM, Jesse Phillips wrote: