There are two problems:
1) In F #, functions must be clean , so a function with no arguments is considered the final value.
To declare an impure function "without arguments", let it take one argument of type unit
let a () = (new System.Random()).Next(1, 1000)
and name it passing the block argument
let list = [ for i in 1 .. 10 -> a () ]
A source
2) A new instance of System.Random() is created each time a is called. This results in identical numbers. To fix this, create an instance only once.
let random = new System.Random() let a () = random.Next(1, 1000) let list = [ for i in 1 .. 10 -> a ()]
This does not apply to F #, read the C # explanation for a better understanding.
source share