UNPKG
lean4-code-actions
Version:
latest (1.1.32)
1.1.32
Refactorings and snippets for Lean 4
lean4-code-actions
/
libs
/
utils
/
sampler.ts
11 lines
(8 loc)
•
285 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
import
{
Random
}
from
'random'
export
type
Sampler
<T> =
(
objects
: T[]
) =>
T |
undefined
export
function
getSampler<T>(
random
:
Random
):
Sampler
<T> {
return
(
array
: T[]
) =>
{
const
index = random.
int
(
0
, array.
length
-
1
)
return
array.
length
? array[index] :
undefined
} }