Share via


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: int

    The index of the first element to set.

  • count
    Type: int

    The number of elements to set.

  • value
    Type: 'T

    The 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 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Collections.Array Module (F#)

Microsoft.FSharp.Collections Namespace (F#)