vendredi 23 octobre 2015

How can I select a random value from a list using F#

I'm new to F# and I'm trying to figure out how to return a random string value from a list/array of strings.

I have a list like this: ["win8FF40", "win10Chrome45", "win7IE11"]

How can I randomly select and return one item from the list above?

Here is my first try:

let combos = ["win8FF40";"win10Chrome45";"win7IE11"]  

let getrandomitem () =  
  let rnd = System.Random()  
  fun (combos : string[]) -> combos.[rnd.Next(combos.Length)]  




Aucun commentaire:

Enregistrer un commentaire