Random.GetValues

namespace Foo

open System

[<AutoOpen>]
module FsExtensions =

    type Random with
        /// Generates an infinite sequence of random numbers within the given range.
        member this.GetValues(minValue, maxValue) =
            Seq.initInfinite (fun _ -> this.Next(minValue, maxValue))
Example:
let rnd = Random()
for x in rnd.GetValues(1, 100) do
    printfn "%d" x

Description

Generates an infinite sequence of random numbers that fall within a given range.

Details

Double click on the code to select all.

 

;