Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.encodingstd.envstd.fsstd.hashstd.httpstd.netstd.jsonstd.mathstd.parsestd.pathstd.processstd.randomstd.raylibstd.regexstd.stringstd.timestd.url

Read as Markdown

Standard Library

std.random

Pseudo-random values from a global xoshiro256++ generator.

Exported functions

pub def seed(value: Int) -> Void

Deterministically reseed the global generator.

Examples

use random from "std.random"

random.seed(42)
const first = random.between(1, 6)
random.seed(42)
@println(first == random.between(1, 6)) # true
pub def float() -> Float

Return a uniform random Float in [0, 1).

Examples

use random from "std.random"

const value = random.float()
@println(value >= 0.0 && value < 1.0) # true
pub def between(min: Int, max: Int) -> Int

Return a uniform random Int between min and max, inclusive.

Examples

use random from "std.random"

const roll = random.between(1, 6)
@println(roll) # An integer from 1 through 6
pub def flip() -> Bool

Return true or false with equal probability.

Examples

use random from "std.random"

@println(if (random.flip()) "heads" else "tails")
pub def chance(probability: Float) -> Bool

Return true with the given probability (0.0 never, 1.0 always).

Examples

use random from "std.random"

if random.chance(0.25)
  @println("Bonus round!")
end
pub def bytes(count: Int) -> List[Int]

Return a list of uniform random bytes (0-255).

Examples

use random from "std.random"

const bytes = random.bytes(16)
@println(@len(bytes)) # 16
pub def choice[T](items: List[T]) -> T

Return a uniformly chosen element of a non-empty list.

Examples

use random from "std.random"

@println(random.choice(["tea", "coffee", "water"])) # One of these drinks
pub def shuffle[T](items: List[T]) -> List[T]

Return a new list with the elements in uniformly random order.

Examples

use random from "std.random"

const players = ["Ada", "Ben", "Cam"]
const order = random.shuffle(players)
@println(order) # A random ordering
@println(players) # [Ada, Ben, Cam] (unchanged)
pub def uuid_v4() -> String

Return a random UUID (version 4, variant 1) as lowercase hex.

Examples

use random from "std.random"

@println(random.uuid_v4()) # A new version-4 UUID