Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Latest commit

 

History

History
77 lines (49 loc) · 1.87 KB

File metadata and controls

77 lines (49 loc) · 1.87 KB
title List.partition<'T> Function (F#)
description List.partition<'T> Function (F#)
keywords visual f#, f#, functional programming
author dend
manager danielfe
ms.date 05/16/2016
ms.topic language-reference
ms.prod visual-studio-dev14
ms.technology devlang-fsharp
ms.assetid b568578a-4f7a-4fd0-a830-bc78537666e0

List.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.List

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

Syntax

// Signature:
List.partition : ('T -> bool) -> 'T list -> 'T list * 'T list

// Usage:
List.partition predicate list

Parameters

predicate Type: 'T ->bool

The function to test the input elements.

list Type: 'Tlist

The input list.

Return Value

A list containing the elements for which the predicate evaluated to true and a list containing the elements for which the predicate evaluated to false.

Remarks

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.

Example

[!code-fsharpMain]

Output

Evens: [2; 4; 6; 8; 10]
Odds: [1; 3; 5; 7; 9]

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

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)