List.Alternate

Syntax

List.Alternate(
    list as list,
    count as number,
    optional repeatInterval as nullable number,
    optional offset as nullable number
) as list

About

通过保留和跳过项来 list返回新列表。 该函数保留 offset 初始项,然后重复跳过 count 项并保留 repeatInterval 项。

  • count:每次要跳过的项数。
  • repeatInterval:每个跳过后要保留的可选项数。 如果未提供此值,则保留初始跳过后的所有项。
  • offset:在重复跳过/保留模式开始之前要保留的可选项数。 默认值为零。

示例 1

创建跳过第一个数字的列表。

用法

List.Alternate({1..10}, 1)

输出

{2, 3, 4, 5, 6, 7, 8, 9, 10}

示例 2

创建跳过其他数字的列表。

用法

List.Alternate({1..10}, 1, 1)

输出

{2, 4, 6, 8, 10}

示例 3

创建一个从 1 开始的列表,并跳过其他每个数字。

用法

List.Alternate({1..10}, 1, 1, 1)

输出

{1, 3, 5, 7, 9}

示例 4

创建从 1 开始、跳过一个值、保留两个值等的列表。

用法

List.Alternate({1..10}, 1, 2, 1)

输出

{1, 3, 4, 6, 7, 9, 10}