共用方式為


FlatMapped 函式

完整名稱:Std.Arrays.FlatMapped

function FlatMapped<'TInput, 'TOutput>(mapper : ('TInput -> 'TOutput[]), array : 'TInput[]) : 'TOutput[]

總結

指定陣列和將陣列元素對應至某些輸出陣列的函式,會傳回每個數位元素的串連輸出陣列。

類型參數

'TInput

array 專案的型別。

'TOutput

mapper 函式會傳回此類型的陣列。

輸入

映射

'TInput'TOutput[] 的函式,用來對應數位元素。

陣列

項目的陣列。

輸出

'TOutput[] 陣列,這是對應函式所產生的所有數位串連。

下列程式代碼會建立一個數位列,其中輸入陣列的每個元素重複兩次。

let repeatedPairs = FlatMapped(x -> Repeated(x, 2), [1, 2, 3]);
// repeatedPairs is [1, 1, 2, 2, 3, 3].