SPECTRALANG_

// DOCS NAVIGATION

std.random — Números Aleatórios_

SOURCE: content/docs/reference/05-stdlib.md05 Stdlib / 8. std.random — Números Aleatórios / Random Numbers

import std.random

random_seed(seed: int) -> unit

PT-BR: Define a semente do gerador de números aleatórios. Use para resultados reproduzíveis.
EN-US: Sets the random number generator seed. Use for reproducible results.

std.random.random_seed(42)

random_int(min: int, max: int) -> int

PT-BR: Retorna um inteiro aleatório em [min, max] (inclusivo).
EN-US: Returns a random integer in [min, max] (inclusive).

let dado = std.random.random_int(1, 6)
    // 1 a 6
let moeda = std.random.random_int(0, 1)
   // 0 ou 1

random_float() -> float

PT-BR: Retorna um float aleatório em [0.0, 1.0).
EN-US: Returns a random float in [0.0, 1.0).

let f = std.random.random_float()
    // ex: 0.7351...

random_bool() -> bool

let b = std.random.random_bool()
    // true ou false