跳至主要内容

List.ReplaceMatchingItems

套用 { old, new } 的每個取代。

Syntax

List.ReplaceMatchingItems(
list as list,
replacements as list,
optional equationCriteria as any
) as list

Remarks

對清單 list 執行指定的取代。取代作業 replacements 是由清單中提供的兩個值 (舊值和新值) 清單組成。 可指定選擇性的等式條件值 equationCriteria,以控制等號比較測試。

Examples

Example #1

根據 {1, 2, 3, 4, 5} 建立清單,並將值 5 以 -5 取代,值 1 則以 -1 取代。

List.ReplaceMatchingItems({1, 2, 3, 4, 5}, {{5, -5}, {1, -1}})

Result:

{-1, 2, 3, 4, -5}

Category

List.Transformation functions