add predicate and reduce function doc
This commit is contained in:
parent
6a952a221b
commit
4c5006d1e7
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user