I am learning F# and would like to know if the following logic to generate random numbers is acceptable.
Could this be written in a more maintainable fashion? Is this code safe?
let hashset = System.Collections.Generic.HashSet<int>()
let mutable continueLooping = true
while (continueLooping) do
let value = System.Random().Next(0, 12)
let success = hashset.Add(value)
continueLooping <- hashset.Count <> 12
UPDATE
let hashset = System.Collections.Generic.HashSet<int>()
let randomGenerator = System.Random()
let mutable continueLooping = true
let expectedLength = 12
while (continueLooping) do
let value = randomGenerator.Next(0, expectedLength)
let success = hashset.Add(value)
continueLooping <- hashset.Count <> expectedLength