Skip to main content

List.RemoveFirstN

Returns a list that skips the specified number of elements at the beginning of the list.

Syntax

List.RemoveFirstN(
list as list,
optional countOrCondition as any
) as list

Remarks

Returns a list that removes the first element of list list. If list is an empty list an empty list is returned.This function takes an optional parameter, countOrCondition, to support removing multiple values as listed below.

  • If a number is specified, up to that many items are removed.
  • If a condition is specified, the returned list begins with the first element in list that meets the criteria. Once an item fails the condition, no further items are considered.
  • If this parameter is null, the default behavior is observed.

Examples

Example #1

Create a list from {1, 2, 3, 4, 5} without the first 3 numbers.

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

Result:

{4, 5}

Example #2

Create a list from {5, 4, 2, 6, 1} that starts with a number less than 3.

List.RemoveFirstN({5, 4, 2, 6, 1}, each _ > 3)

Result:

{2, 6, 1}

Category

List.Transformation functions