randomlib
A random number library for Gleam
This package provides various function to generate random output for different types The random generation should be the same between Erlang and Javascript targets
gleam add randomlib@1
import randomlib
pub fn main() {
randomlib.choice(randomlib.new(), ["Red", "Green", "Blue"])
let #(val, rnd) = randomlib.next_byte(randomlib.with_seed(13470613))
let #(val2, rnd) = randomlib.next_float(rnd)
io.debug(val)
io.debug(val2)
}
// -> 50
// -> 0.9460694304884285
Further documentation can be found at https://hexdocs.pm/randomlib.
Development
gleam run # Run the project
gleam test # Run the tests