共用方式為


Collections.Array 模組 (F#)

提供在陣列上的基本作業。

命名空間/模組路徑: Microsoft.FSharp.Collections

組件:FSharp.Core (在 FSharp.Core.dll 中)

module Array

備註

如需 F# 陣列的概觀,請參閱陣列 (F#)

說明

append : 'T [] -> 'T [] -> 'T []

會建立一個陣列,其中包含後面接著另一個陣列的元素的一個陣列的元素。

average : ^T [] -> ^T

傳回陣列中的元素的平均值。

averageBy : ('T -> ^U) -> 'T [] -> ^U

傳回將函式套用到陣列中的每個項目所產生的元素的平均值。

blit : 'T [] -> int -> 'T [] -> int -> int -> unit

讀取一個陣列中某個範圍的項目,並將它們寫入成另一個。

choose : ('T ->'U option) -> 'T [] -> 'U []

陣列中的每個項目要套用所提供的函式。 傳回陣列,包含在結果 x函式傳回的每個項目為 Some(x)

collect : ('T -> 'U []) -> 'T [] -> 'U []

陣列中的每個項目要套用所提供的函式、 串連在的結果並傳回組合的陣列。

concat : seq<'T []> -> 'T []

建立陣列,其中包含每個陣列所提供的序列的項目。

copy : 'T -> 'T []

建立包含所提供的陣列元素的陣列。

create : int -> 'T -> 'T []

建立的陣列,其元素為所有一開始所提供的值。

empty : 'T []

傳回所指定型別的空陣列。

exists : ('T -> bool) -> 'T [] -> bool

測試是否陣列中的任何項目符合提供的述詞。

exists2 : ('T1 -> 'T2 -> bool) -> 'T1 [] -> 'T2 [] -> bool

測試是否有任何的兩個陣列的相對應項目對符合所提供的條件。

fill : 'T [] -> int -> int -> 'T -> unit

提供的值來填滿陣列中的項目範圍。

filter : ('T -> bool) -> 'T [] -> 'T []

傳回包含只提供的條件傳回 所提供的陣列元素的集合 true

find : ('T -> bool) -> 'T [] -> 'T

傳回第一個項目,為其提供的函式會傳回 true 如果沒有這類項目,則引發 KeyNotFoundException

findIndex : ('T -> bool) -> 'T [] -> int

傳回符合所提供的條件的陣列中的第一個項目的索引。 引發 KeyNotFoundException如果沒有任何項目符合 條件。

fold : ('State -> 'T -> 'State) -> 'State -> 'T [] -> 'State

要套用函式的執行緒透過計算累加引數的陣列的每一個項目。 如果輸入的函式是 f和陣列元素是 i0...iN,這個函式會計算 f (...(f s i0)...) iN

fold2 : ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> 'T1 [] -> 'T2 [] -> 'State

適用於項目組的函式,從兩個提供的陣列左到右,執行緒透過計算累加引數。 兩個輸入的陣列必須有相同的長度 ; 否則 ArgumentException引發

foldBack : ('T -> 'State -> 'State) -> 'T [] -> 'State -> 'State

要套用函式的執行緒透過計算累加引數的陣列的每一個項目。 如果輸入的函式是 f和陣列元素是 i0...iN,這個函式會計算 f i0 (...(f iN s))

foldBack2 : ('T1 -> 'T2 -> 'State -> 'State) -> 'T1 [] -> 'T2 [] -> 'State -> 'State

從兩個提供陣列,右到左,執行緒累加引數計算透過套組元素的函式。 兩個輸入的陣列必須有相同的長度 ; 否則 ArgumentException引發

forall : ('T -> bool) -> 'T [] -> bool

測試是否陣列的所有元素都符合所提供的條件。

forall2 : ('T1 -> 'T2 -> bool) -> 'T1 [] -> 'T2 [] -> bool

測試是否符合所提供的條件的兩個提供陣列的所有對應的項目。

get : 'T [] -> int -> 'T

取得陣列中的項目。

init : int -> (int -> 'T) -> 'T []

若要建立提供維度的陣列會使用所提供的函式。

isEmpty : 'T [] -> bool

測試是否陣列中有任何項目。

iter : ('T -> unit) -> 'T [] -> unit

陣列中的每個項目要套用所提供的函式。

iter2 : ('T1 -> 'T2 -> unit) -> 'T1 [] -> 'T2 [] -> unit)

Applies the supplied function to a pair of elements from matching indexes in two arrays. The two arrays must have the same lengths; otherwise, ArgumentException is raised.

iteri : (int -> 'T -> unit) -> 'T [] -> unit

陣列中的每個項目要套用所提供的函式。 The integer passed to the function indicates the index of the element.

iteri2 : (int -> 'T1 -> 'T2 -> unit) -> 'T1 [] -> 'T2 [] -> unit

Applies the supplied function to a pair of elements from matching indexes in two arrays, also passing the index of the elements. The two arrays must have the same lengths; otherwise, an ArgumentException is raised.

length : 'T [] -> int

傳回陣列的長度。 The Length property does the same thing.

map : ('T -> 'U) -> 'T [] -> 'U []

Creates an array whose elements are the results of applying the supplied function to each of the elements of a supplied array.

map2 : ('T1 -> 'T2 -> 'U) -> 'T1 [] -> 'T2 [] -> 'U []

Creates an array whose elements are the results of applying the supplied function to the corresponding elements of two supplied arrays. 兩個輸入的陣列必須有相同的長度 ; 否則 ArgumentException引發

mapi : (int -> 'T -> 'U) -> 'T [] -> 'U []

Creates an array whose elements are the results of applying the supplied function to each of the elements of a supplied array. 傳遞給函數的整數索引表示轉換之項目的索引。

mapi2 : (int -> 'T1 -> 'T2 -> 'U) -> 'T1 [] -> 'T2 [] -> 'U []

建立的陣列,其元素會套用兩個成對也傳遞項目之索引的集合中的相對應的項目提供的函數的結果。 兩個輸入的陣列必須有相同的長度 ; 否則 ArgumentException引發

max : 'T [] -> 'T

傳回陣列的所有元素的最大值。 Operators.max 用來比較項目。

maxBy : ('T -> 'U) -> 'T [] -> 'T

透過比較,傳回最大的所有元素的陣列,Operators.max 上函式的結果。

min : ('T [] -> 'T

傳回陣列的所有元素的最小值。 Operators.min 用來比較項目。

minBy : ('T -> 'U) -> 'T [] -> 'T

傳回陣列的所有元素的最小值。 Operators.min 用來比較項目。

ofList : 'T list -> 'T []

建立一個從提供的清單。

ofSeq : seq<'T> -> 'T []

建立一個從提供可列舉的物件。

Partition - 資料分割 : ('T -> bool) -> 'T [] -> 'T [] * 'T []

將陣列分割為兩個陣列一個包含項目,為其提供的條件傳回 true,及其他包含那些其傳回 false

permute : (int -> int) -> 'T [] -> 'T []

permutes 到指定的排列依據陣列中的元素。

pick : ('T -> 'U option) -> 'T [] -> 'U

套用所提供的函式提供陣列傳回第一個結果,則函數會傳回 Some(x)某些 的連續的項目到 x 如果函式不會傳回 Some(x)、 KeyNotFoundException引發

reduce : ('T -> 'T -> 'T) -> 'T [] -> 'T

要套用函式的執行緒透過計算累加引數的陣列的每一個項目。 如果輸入的函式是 f和陣列元素是 i0...iN,這個函式會計算 f (...(f i0 i1)...) iN 如果陣列具有大小為零, ArgumentException引發

reduceBack : ('T -> 'T -> 'T) -> 'T [] -> 'T

要套用函式的執行緒透過計算累加引數的陣列的每一個項目。 如果輸入的函式是 f和各個元素,是 i0...iN,這個函式會計算 f i0 (...(f iN-1 iN)) 如果陣列具有大小為零, ArgumentException引發

rev : 'T [] -> 'T []

反轉所提供的陣列中項目的順序。

scan : ('State -> 'T -> 'State) -> 'State -> 'T [] -> 'State [])

模仿 摺疊 ,但傳回與最終結果的中繼結果。

scanBack : ('T -> 'State -> 'State) -> 'T [] -> 'State -> 'State []

模仿 foldBack ,但傳回搭配最終結果的中繼結果。

set : 'T [] -> int -> 'T -> unit

設定陣列的元素。

sort : 'T[] -> 'T []

排序陣列的元素,並傳回新的陣列。 Operators.compare 用來比較項目。

sortBy : ('T -> 'Key) -> 'T [] -> 'T []

依使用所提供的函式來轉換為型別在其排序作業為基礎,並傳回新的陣列元素的陣列元素。 Operators.compare 用來比較項目。

sortInPlace : 'T [] -> unit

排序陣列的元素,藉由變更陣列中的位置,使用提供的比較函式。 Operators.compare 用來比較項目。

sortInPlaceBy : ('T -> 'Key) -> 'T [] -> unit

依變更機碼使用提供的投射在位置,陣列的陣列元素。 Operators.compare 用來比較項目。

sortInPlaceWith : ('T -> 'T -> int) -> 'T [] -> unit

依使用提供的比較函式來變更就地陣列的陣列元素。

sortWith : ('T -> 'T -> int) -> 'T [] -> 'T []

使用提供的比較] 函數來排序陣列的元素,並傳回新的陣列。

sub : 'T [] -> int -> int -> 'T []

建立陣列,包含指定的開始索引和長度上,提供的 subrange。

sum : 'T [] -> ^T

傳回陣列中元素的總和。

sumBy : ('T -> ^U) -> 'T [] -> ^U

傳回將函式套用到陣列中的每個項目所產生結果的總和。

toList : 'T [] -> 'T list

將提供的陣列轉換至清單中。

toSeq : 'T [] -> seq<'T>

為序列,檢視所提供的陣列。

tryFind : ('T -> bool) -> 'T [] -> 'T option

傳回第一個項目中所提供的陣列為其提供的函式會傳回 true 傳回 None如果沒有這類項目存在

tryFindIndex : ('T -> bool) -> 'T [] -> int option

傳回符合所提供的條件的陣列中的第一個項目的索引。

tryPick : ('T -> 'U option) -> 'T [] -> 'U option

會提供函式套用到所提供的陣列中的連續的項目,並傳回第一個結果,則函數會傳回 Some(x)某些 x 如果函式不會傳回 Some(x)、 None傳回

unzip : ('T1 * 'T2) [] -> 'T1 [] * 'T2 []

分割成兩個陣列的有序元組的有序元組配對的陣列。

unzip3 : ('T1 * 'T2 * 'T3) [] -> 'T1 [] * 'T2 [] * 'T3 []

分割的三個陣列的有序元組 Tuple 的三個元素的陣列。

zeroCreate : int -> 'T []

建立的陣列,其項目一開始設定為在 的 Unchecked.defaultof <'T> 預設值。

zip : 'T1 [] -> 'T2 [] -> ('T1 * 'T2) []

有序元組中有兩個元素的陣列,結合了兩個陣列。 兩個陣列都必須有相同的長度 ; 否則 ArgumentException引發

zip3 : 'T1 [] -> 'T2 [] -> 'T3 [] -> ('T1 * 'T2 * 'T3) []

結合三個陣列,有序元組中有三個元素的陣列。 三個陣列必須有相同的長度 ; 否則 ArgumentException引發

平台

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# 執行階段

支援版本:2.0、4.0

Silverlight

支援版本:3

請參閱

參考

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

Array

Collections.Array2D 模組 (F#)

Collections.Array3D 模組 (F#)

Collections.Array4D 模組 (F#)

其他資源

陣列 (F#)