Array.fill<'T> Function (F#)
Fills a range of elements of the array with the given value.
Namespace/Module Path: Microsoft.FSharp.Collections.Array
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
Array.fill : 'T [] -> int -> int -> 'T -> unit
// Usage:
Array.fill target targetIndex count value
Parameters
target
Type: 'T []The target array.
targetIndex
Type: intThe index of the first element to set.
count
Type: intThe number of elements to set.
value
Type: 'TThe value to set.
Remarks
This function is named Fill in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.
Example
The following example demonstrates the use of Array.fill to overwrite a section of an array with zeroes.
let arrayFill1 = [| 1 .. 25 |]
Array.fill arrayFill1 2 20 0
printfn "%A" arrayFill1
[|1; 2; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 23; 24; 25|]
Platforms
Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2
Version Information
F# Runtime
Supported in: 2.0, 4.0
Silverlight
Supported in: 3