Table of contents
Collapse the table of content
Expand the table of content

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

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

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: 'Tlist

The input list.

Return Value

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.


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


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


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#)

© 2020 Microsoft