Export (0) Print
Expand All
Expand Minimize

Array.collect<'T,'U> Function (F#)

For each element of the array, applies the given function. Concatenates all the results and return the combined array.

Namespace/Module Path: Microsoft.FSharp.Collections.Array

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
Array.collect : ('T -> 'U []) -> 'T [] -> 'U []

// Usage:
Array.collect mapping array

mapping

Type: 'T -> 'U []

The function to create sub-arrays from the input array elements.

array

Type: 'T []

The input array.

The concatenation of the subarrays.

The following code demonstrates the use of Array.collect to concatenate subarrays that are generated from each array element.

printfn "%A" (Array.collect (fun elem -> [| 0 .. elem |]) [| 1; 5; 10|])
[|0; 1; 0; 1; 2; 3; 4; 5; 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]

This function is named Collect in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Show:
© 2014 Microsoft