Skip to content

Instantly share code, notes, and snippets.

@kjagiello
Created February 24, 2013 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjagiello/d3c80335600a9633d58d to your computer and use it in GitHub Desktop.
Save kjagiello/d3c80335600a9633d58d to your computer and use it in GitHub Desktop.
local
fun rmod x y = x - y * Real.realFloor (x / y);
val a = 16807.0;
val m = 2147483647.0;
val random_seed = ref 1.0;
in
fun random () =
let
val r = rmod (a * ! random_seed) m
in
random_seed := r;
Real.floor r
end
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment