List.RemoveLastN

Last updated 5 months ago

List.RemoveLastN

Returns a list that removes the specified number of elements from the end of the list.

function (list as list, optional countOrCondition as nullable any) as list

Description

Returns a list that removes the last countOrCondition elements from the end of list list. If list has less than countOrCondition elements, an empty list is returned.

Category

List.Transformation functions

Examples

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

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

{1, 2}

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

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

{5, 4, 2}