This is a good explanation, thank you!
My use case for this is for a package, and a user wouldn’t be able to manage handling rng constantly. I’ve tried to deal with this using state but if there are a number of calls to the function then it doesn’t resolve after a while (resulting in repeats).
Do you happen to know if there is some way to update state?
Here is what I tried (I realize the nested expression isn’t necessary, but you get the idea):
#import "@preview/suiji:0.4.0": *
#let rng = state("rng", gen-rng(1))
#let randomize(options) = {
context {
let _rng = none
let _options = none
(_rng, _options) = shuffle(rng.get(), options)
rng.update(_rng)
_options.join(",")
}
}
#let options = ("A", "B", "C", "D")
#randomize(options)
#randomize(options)
#randomize(options)
#randomize(options)
#randomize(options)
#randomize(options)
#randomize(options)