random / seeding / shuffle #1902
inoas
started this conversation in
Ideas & suggestions
Replies: 1 comment
-
This is kind of the reason why I ended up implementing my own PRNG as it's then also possible ensure consistency across the targets: https://github.com/nicklasxyz/gleam_stats/blob/v1.1.0/src/gleam_stats/generators.gleam#L166-L166 Alg: https://www.pcg-random.org/ Aligning the functionality across the two platforms becomes a bit of a mess otherwise. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Caveat: This will rely on default args for good ergonomics
list.shuffle
should take an optional callback that can be used instead statically relying onfloat.random(0.0, 1.0)
.float.random
andint.random
to make it easier to generate slower but better values across the Erlang and Javascript by relying onrandom_float
andrandom_int
functions togleam/erlang
and maybegleam/javascript
that allow to set a seeder and even constant seed values, for Erlang see: https://www.erlang.org/doc/man/rand.html#description -It seems https://www.erlang.org/doc/man/rand.html#seed-1 can use the value of https://www.erlang.org/doc/man/rand.html#export_seed-0 to capture and then return to the previous global state?
Beta Was this translation helpful? Give feedback.
All reactions