diff --git a/data/scripts/types/list.lua b/data/scripts/types/list.lua index 47f6525..3a06476 100644 --- a/data/scripts/types/list.lua +++ b/data/scripts/types/list.lua @@ -68,16 +68,23 @@ function List:pop() return table.remove(self, #self) end ----Reduce. ----@param f function called with element, accumulator, index ----@param init any initial value of accumulator +---Removes the first element in the list and returns it. ---@return any +function List:pop_front() + return table.remove(self, 1) +end + +---Reduce. +---@generic T +---@param f fun(element: any, accumulator: T, index: integer): T +---@param init T|nil initial value of accumulator +---@return T function List:reduce(f, init) return reduce(self, f, init) end ---Returns a new List of all elements of this list that match the predicate function. ----@param predicate function called with element +---@param predicate fun(element: any): boolean ---@return List function List:filter(predicate) return filter(self, predicate)