aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-List.random.3
blob: 9da436989298d542a09c8056c31e66642f139472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH List.random 3 2025-04-21T14:44:34.259075 "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 `min` and `max` (inclusive). (Used for deterministic pseudorandom number generation) 	none
.TE
.SH RETURN
A random element from the list.

.SH EXAMPLES
.EX
>> [10, 20, 30].random()
= 20
.EE