Is there a way in which to pass a function as input to another function, with
the arguments of the first function already determined?
The case I'm thinking of is one where I have a function which wants to take a
random number generation scheme, and use it on several occasions, without having
On 23/04/12 01:19, Joseph Rushton Wakeling wrote:
void main()
{
foreach(double upper; iota(1.0, 2.0, 0.2) ) {
double delegate() rng = () {
return uniform(0.0, 1.0);
};
printRandomNumbers(rng,10);
}
}
That was meant to be,
double delegate() rng
On 04/22/2012 04:19 PM, Joseph Rushton Wakeling wrote:
Is there a way in which to pass a function as input to another function,
with the arguments of the first function already determined?
The case I'm thinking of is one where I have a function which wants to
take a random number generation
On 23/04/12 06:10, Ali Çehreli wrote:
You just need to call the delegate with the function call syntax:
writeln(rng());
... but what I get in my code is that printRandomNumbers then prints out n times
the _same number_, instead of 5 different ones. i.e. when the delegate is
passed its
On Sunday, 22 April 2012 at 23:19:52 UTC, Joseph Rushton Wakeling
wrote:
import std.random, std.range, std.stdio;
void
printRandomNumbers(RandomNumberGenerator)(RandomNumberGenerator
rng, size_t n)
{
foreach(i; 0..n)