stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

Function to take a number of random values from a list

Open sobolevn opened this issue 1 year ago • 10 comments
trafficstars

I started looking at the state of random in Gleam and I have several ideas.

  1. int.random and float.random do not have seeds. It might be a problem for libraries. For example: if you want a fake-data library for tests: you need to have the same data based on some test seed value. Otherwise, you won't have reproducable failures. https://docs.python.org/3/library/random.html#notes-on-reproducibility
  2. There's no int.random_range(x, y) function, which would generate an int from range >=x, <y. I think that this function is essential
  3. There's no choice(List) function, which in my experience is the second most frequently used random function in Python.

Maybe we should add random module with the needed functions and a nice api for Seed(Int)?

sobolevn avatar Aug 22 '24 06:08 sobolevn