Seq.truncate<'T> 関数 (F#)

列挙時に最大 N 要素を返すシーケンスを返します。

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

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

// Signature:
Seq.truncate : int -> seq<'T> -> seq<'T>

// Usage:
Seq.truncate count source

パラメーター

  • count
    型: int

    列挙する最大項目数。

  • source
    型: seq<'T>

    入力シーケンス。

例外

例外

状態

ArgumentNullException

入力シーケンスが null の場合にスローされます。

戻り値

結果のシーケンス。

解説

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

使用例

Seq.truncate を使用する方法と、Seq.take との動作の比較を次の例に示します。

let mySeq = seq { for i in 1 .. 10 -> i*i }
let truncatedSeq = Seq.truncate 5 mySeq
let takenSeq = Seq.take 5 mySeq

let truncatedSeq2 = Seq.truncate 20 mySeq
let takenSeq2 = Seq.take 20 mySeq

let printSeq seq1 = Seq.iter (printf "%A ") seq1; printfn ""

// Up to this point, the sequences are not evaluated.
// The following code causes the sequences to be evaluated.
truncatedSeq |> printSeq
truncatedSeq2 |> printSeq
takenSeq |> printSeq
// The following line produces a run-time error (in printSeq):
takenSeq2 |> printSeq
  

プラットフォーム

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

バージョン情報

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

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

参照

関連項目

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

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