Expand Minimize

List.isEmpty<'T> Function (F#)

Tests whether a list is empty.

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

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

// Signature:
List.isEmpty : 'T list -> bool

// Usage:
List.isEmpty list

list

Type: 'T list

The input list.

true if the list is empty. Otherwise, returns false.

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

The following code shows how to use List.isEmpty.


let printList list1 = 
    if (List.isEmpty list1) then
        printfn "There are no elements in this list."
    else
        printfn "This list contains the following elements:"
        List.iter (fun elem -> printf "%A " elem) list1
        printfn ""
printList [ "test1"; "test2" ]
printList [ ]


Output

This list contains the following elements:
"test1" "test2" 
There are no elements in this list.

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft