1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Seeding And Generating Random Integers as a reason til

This commit is contained in:
jbranchaud
2018-03-22 14:13:23 -05:00
parent 5beeac72ad
commit 13dd9b739a
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
# Seeding And Generating Random Integers
It is easy enough to generate a series of random numbers using the `Random`
module's `int` function.
```reason
Random.int(10);
```
This will generate a random integer between 0 and 9.
You may notice that the randomness is the same each time you run your
program. That is because you have fixed seed. To make sure you have a
different seed each time your program runs, you can initialize the random
number generator with something different at each run, such as the current
time.
```reason
Random.init(int_of_float(Js.Date.now()));
```