summaryrefslogtreecommitdiff
path: root/lib/std/rand.myr
diff options
context:
space:
mode:
authorandrewc <andrew_chambers@trimble.com>2016-01-14 17:58:48 +1300
committerandrewc <andrew_chambers@trimble.com>2016-01-14 17:58:48 +1300
commite157c1733098280a2e0bcfe3fa59bc7c46dfc131 (patch)
tree67311e7c3d0f769ac6f0e19d4c64e4fb8de9d982 /lib/std/rand.myr
parentaf8bf2d89e9b7c066a13f450f71f800b562d78c0 (diff)
downloadmc-e157c1733098280a2e0bcfe3fa59bc7c46dfc131.tar.gz
add randbytes to stdlib
Diffstat (limited to 'lib/std/rand.myr')
-rw-r--r--lib/std/rand.myr6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/std/rand.myr b/lib/std/rand.myr
index 566a4cf..91dd774 100644
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -56,6 +56,7 @@ pkg std =
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 @@ generic randnum = {
-> 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 @@ const rngrandbytes = {rng, buf
r >>= 8
;;
-> n
-
}
/* updates random number generator state when we tick over. */