ref: 5db63a604d13a8cff98c78c4977bf1cde43ead88
parent: af8bf2d89e9b7c066a13f450f71f800b562d78c0
parent: e157c1733098280a2e0bcfe3fa59bc7c46dfc131
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Jan 13 18:17:09 EST 2016
Merge pull request #41 from andrewchambers/randbytes 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. */