samedi 16 juillet 2016

F# function conciseness when genrating random numbers

Is there a reason why one writes the line:

(fun max -> rndGen.Next(max))  

http://ift.tt/29KxOMB

let NextRandom =
    let rndGen = new System.Random(int System.DateTime.Now.Ticks)
    (fun max -> rndGen.Next(max))

Instead of just declaring the param max upfront and calling rndGen.Next(max), like this?

let NextRandom (max: int) =
    let rndGen = new System.Random(int System.DateTime.Now.Ticks)
    rndGen.Next(max)




Aucun commentaire:

Enregistrer un commentaire