Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Array.partition<'T> Function (F#)

Splits the collection into two collections, containing the elements for which the given predicate returns true and false respectively.

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

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

// Signature:
Array.partition : ('T -> bool) -> 'T [] -> 'T [] * 'T []

// Usage:
Array.partition predicate array


Type: 'T -> bool

The function to test the input elements.


Type: 'T []

The input array.

A pair of arrays. The first containing the elements the predicate for which the predicate evaluated to true, and the second containing those for which the predicate evaluated to false.

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

The following code illustrates the use of Array.partition.

let removeOutliers array1 min max =
    Array.partition (fun elem -> elem > min && elem < max) array1
    |> fst
removeOutliers [| 1 .. 100 |] 50 60
|> printf "%A"


[|51; 52; 53; 54; 55; 56; 57; 58; 59|]

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

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

© 2015 Microsoft