summaryrefslogtreecommitdiff
path: root/lib/std/rand.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-10 17:19:27 -0700
committerOri Bernstein <ori@eigenstate.org>2015-10-10 17:19:27 -0700
commit776a9e4ed35369c9c8553e3035daa026e00495e9 (patch)
tree99beac4de9952263367f3a3511838b1beea8d356 /lib/std/rand.myr
parent954728ed5cc60e638cd858d232c5851f72ad7343 (diff)
downloadmc-776a9e4ed35369c9c8553e3035daa026e00495e9.tar.gz
Some API tweaks to make things match the docs.
Diffstat (limited to 'lib/std/rand.myr')
-rw-r--r--lib/std/rand.myr13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/std/rand.myr b/lib/std/rand.myr
index 351bf8d..2e64fe7 100644
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -54,6 +54,7 @@ pkg std =
const freerng : (rng : rng# -> void)
generic rand : (lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
+ generic randnum : (-> @a::(numeric,integral))
generic rngrand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))
generic rngrandnum : (rng : rng# -> @a::(numeric,integral))
@@ -84,10 +85,6 @@ const freerng = {rng
free(rng)
}
-generic rand = {lo, hi
- -> rngrand(_rng, lo, hi)
-}
-
/* initializes a random number generator from the seed `seed`. */
const init = {rng, seed
for var i = 0; i < 624; i++
@@ -97,6 +94,14 @@ const init = {rng, seed
rng.i = 624
}
+generic rand = {lo, hi
+ -> rngrand(_rng, lo, hi)
+}
+
+generic randnum = {
+ -> rngrandnum(_rng)
+}
+
/*
Generates a random integer from `rng` in the range [lo, hi),
returning the value. The range [lo, hi) must be positive,