I am trying to use F # to create a list of random triples -> two random numbers and their sum:
let foo minNum maxNum =
let rnd = System.Random()
let first = rnd.Next(minNum, maxNum)
let second = rnd.Next(minNum, maxNum)
let third = first + second
first, second, third
which can be called that and works well (always gives a new random number) (when using F # interactive)
foo 0 50
When trying to generate a list of random triples like this
List.init 100 (fun index -> foo 0 50)
I would like it to be a list of 100 randomized triples , but instead they all have the same meaning. I see that the function is independent of the index and therefore does not need to be recalculated, but I'm not sure how to get around it (I tried to enter the index as an unused dummy variable, also tried to present the index as a random seed, but it didn’t help)
HK_CH source
share