12345678910111213141516171819202122232425262728293031323334353637383940 | '\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH List.random 3 2026-03-14 "Tomo man-pages"
.SH NAME
List.random \- pick a random element
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.random\ :\ func(list:\ [T],\ random:\ func(min,max:Int64->Int64)?\ =\ none\ ->\ T?)
.fi
.SH DESCRIPTION
Selects a random element from the list.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
list [T] The list from which to select a random element. -
random func(min,max:Int64->Int64)? If provided, this function will be used to get a random index in the list. Returned values must be between \fBmin\fR and \fBmax\fR (inclusive). (Used for deterministic pseudorandom number generation) none
.TE
.SH RETURN
A random element from the list or `none` if the list is empty.
.SH EXAMPLES
.EX
nums := [10, 20, 30]
pick := nums.random()!
assert nums.has(pick)
empty : [Int]
assert empty.random() == none
.EE
.SH SEE ALSO
.BR Tomo-List (3)
|