List.TransformMany
语法
List.TransformMany(list as list, collectionTransform as function, resultTransform as function) as list
关于
返回一个列表,其元素是基于输入列表投射而来的。
collectionTransform
函数将每个元素转换为中间列表,resultTransform
函数接收原始元素以及中间列表中的项,以便构造最终结果。
collectionTransform
函数具有签名 (x as any) as list => ...
,其中 x
是 list
中的元素。 resultTransform
函数将投影结果的形状,并具有签名 (x as any, y as any) as any => ...
,其中 x
是 list
中的元素,y
是通过将 x
传递给 collectionTransform
生成的列表中的元素。
示例 1
平展人员及其宠物的列表。
使用情况
List.TransformMany(
{
[Name = "Alice", Pets = {"Scruffy", "Sam"}],
[Name = "Bob", Pets = {"Walker"}]
},
each [Pets],
(person, pet) => [Name = person[Name], Pet = pet]
)
输出
{
[Name = "Alice", Pet = "Scruffy"],
[Name = "Alice", Pet = "Sam"],
[Name = "Bob", Pet = "Walker"]
}