This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
static const String _title = 'Flutter Code Sample'; | |
@override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://en.wikipedia.org/wiki/Linear_congruential_generator | |
// See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator | |
// Original Lehmer RNG construction | |
const m = 65537 // (2 ^ 16) + 1, a fermat prime | |
const a = 75 // a primitive root modulo | |
const x0 = 65536 // a seed number, greater than '0', less than 'm' | |
const md = m - 1 // a floating-point devider | |
// Lehmer random number generator formula | |
function rng(x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//See: https://en.wikipedia.org/wiki/Linear_congruential_generator | |
//See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator | |
public class Random | |
{ | |
private const int m = 65537; // (2 ^ 16) + 1, a Fermat prime | |
private const int a = 75; // a Primitive root modulo | |
private const int x0 = 65536; // Number, greater than '0', less than 'm' | |
private static int ox, cx; // Original seed, Current seed | |
private static readonly float md; // floating-point devider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Run multiple async/promise functions with parameters in parallel | |
* @param {[[Promise, ...any]]} promises | |
* @returns {Promise<any[]>} values | errors | |
*/ | |
function promiseAll(...promises) { | |
return new Promise((resolve, reject) => { | |
let values = []; let errors = []; | |
function check() { | |
if (values.length + errors.length === promises.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- See: https://en.wikipedia.org/wiki/Linear_congruential_generator | |
-- See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator | |
-- Original Lehmer RNG construction | |
local m = 65537 -- (2 ^ 16) + 1, a fermat prime | |
local a = 75 -- a primitive root modulo | |
local x0 = 65536 -- a seed number, greater than '0', less than 'm' | |
local md = m - 1 -- a floating-point devider | |
-- Lehmer random number generator formula | |
local function rng(x) |