How to select some elements from array randomly?
let array = ("one", "two", "three", "1", "2", "3", "4")
array.pick(10)
How to select some elements from array randomly?
let array = ("one", "two", "three", "1", "2", "3", "4")
array.pick(10)
The
suiji
package provides a pseudo-random number generator. With it, you can write apick
function that returns random elements from the array:Note that this function will do the following:
This is because there is no true source of randomness in Typst so that incremental recompilation works. You can factor out the seed argument and pass a different seed every time if you need to get different picks at each call site.