Narra

Reference

std/random

std/random

A seeded random number generator that gives the same numbers on every platform.

narra
import * as Random from "std/random"

The guide teaches it in chapter 2, Values and types.

This page is generated by scripts/std/generate.nra from narrac query --json interface std/random. Do not edit it.

Types

Random

narra
export struct Random {
  state: u64
}

Functions: seeded, fromSystem, nextBits, nextInt, nextFloat, shuffle.

Functions

seeded

narra
export function seeded(seed: int): Random

Effects: none.

fromSystem

narra
export function fromSystem(): Random uses io

Effects: io.

nextBits

narra
export function nextBits(mutable random: Random): u64

Effects: none.

nextInt

narra
export function nextInt(mutable random: Random, low: int, high: int): Option<int>

Effects: none.

nextFloat

narra
export function nextFloat(mutable random: Random): f64

Effects: none.

shuffle

narra
export function shuffle<T>(mutable random: Random, mutable items: Array<T>)

Effects: none.