在代码中使用 Filter 数组函数来代替 apply to each 循环,从而减少代码的复杂度并提高执行效率。
示例代码:
// 避免不必要的 apply to each
items = items
|> Filter(item => item.IsActive)
|> ApplyToEach(item => item.Name);
// 使用 Filter 函数替代 apply to each
activeItems = items
|> Filter(item => item.IsActive);
activeItemNames = activeItems
|> Select(item => item.Name);