Share via


List.isEmpty<'T> 関数 (F#)

リストが空であるかどうかをテストします。

名前空間/モジュール パス: Microsoft.FSharp.Collections.List

アセンブリ: FSharp.Core (FSharp.Core.dll)

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

// Usage:
List.isEmpty list

パラメーター

  • list
    型: 'Tlist

    入力リスト。

戻り値

リストが空の場合は true。それ以外の場合は、false を返します。

解説

この関数は、コンパイルされたアセンブリでは IsEmpty という名前です。F# 以外の .NET 言語から、またはリフレクションを使用してこの関数にアクセスする場合は、この名前を使用します。

使用例

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 [ ]

出力

  

プラットフォーム

Windows 8、Windows 7、Windows Server 2012 で Windows Server 2008 R2

バージョン情報

F# コア ライブラリのバージョン

サポート: ポータブル 2.0、4.0

参照

関連項目

Collections.List モジュール (F#)

Microsoft.FSharp.Collections 名前空間 (F#)