ref: e157c1733098280a2e0bcfe3fa59bc7c46dfc131
parent: af8bf2d89e9b7c066a13f450f71f800b562d78c0
author: andrewc <andrew_chambers@trimble.com>
date: Thu Jan 14 12:58:48 EST 2016
add randbytes to stdlib
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -56,6 +56,7 @@
generic rand : (lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
generic randnum : (-> @a::(numeric,integral))
+ const randbytes : (buf : byte[:] -> size)
generic rngrand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
generic rngrandnum : (rng : rng# -> @a::(numeric,integral))
@@ -103,6 +104,10 @@
-> rngrandnum(_rng)
}
+const randbytes = {buf
+ -> rngrandbytes(_rng, buf)
+}
+
/*
Generates a random integer from `rng` in the range [lo, hi),
returning the value. The range [lo, hi) must be positive,
@@ -182,7 +187,6 @@
r >>= 8
;;
-> n
-
}
/* updates random number generator state when we tick over. */