Skip to content

Instantly share code, notes, and snippets.

@theoknock
Last active July 8, 2022 19:42
Show Gist options
  • Save theoknock/b1ed573201eb95d73985128db0aa8658 to your computer and use it in GitHub Desktop.
Save theoknock/b1ed573201eb95d73985128db0aa8658 to your computer and use it in GitHub Desktop.
Generating weight-distributed random number calculations Blocks template
static double (^(^(^random_generator)(double(^(*))(double)))(double(^(*))(double)))(void) = ^ (double(^(*distributor))(double)) {
srand48((unsigned int)time(0));
return ^ (double(^(*number))(double)) {
static double random;
return ^ double {
return (*number)((*distributor)((random = drand48())));
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment