random
import randomFunctions
Section titled “Functions”| Function | Signature | Description |
|---|---|---|
int | (Int, Int) -> Int | Generate a random integer between min and max (inclusive). |
float | () -> Float | Generate a random float between 0.0 and 1.0. |
choice | (List[T]) -> Option[T] | Pick a random element from a list, or none if empty. |
shuffle | (List[T]) -> List[T] | Return a randomly shuffled copy of a list. |
Reference
Section titled “Reference”random.int(min: Int, max: Int) -> Int
Section titled “random.int(min: Int, max: Int) -> Int”Generate a random integer between min and max (inclusive).
random.int(1, 100) // => 42random.float() -> Float
Section titled “random.float() -> Float”Generate a random float between 0.0 and 1.0.
random.float() // => 0.7321random.choice(xs: List[T]) -> Option[T]
Section titled “random.choice(xs: List[T]) -> Option[T]”Pick a random element from a list, or none if empty.
random.choice(["a", "b", "c"]) // => some("b")random.shuffle(xs: List[T]) -> List[T]
Section titled “random.shuffle(xs: List[T]) -> List[T]”Return a randomly shuffled copy of a list.
random.shuffle([1, 2, 3]) // => [3, 1, 2]