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)
|
return table.remove(self, #self)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Reduce.
|
---Removes the first element in the list and returns it.
|
||||||
---@param f function called with element, accumulator, index
|
|
||||||
---@param init any initial value of accumulator
|
|
||||||
---@return any
|
---@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)
|
function List:reduce(f, init)
|
||||||
return reduce(self, f, init)
|
return reduce(self, f, init)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns a new List of all elements of this list that match the predicate function.
|
---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
|
---@return List
|
||||||
function List:filter(predicate)
|
function List:filter(predicate)
|
||||||
return filter(self, predicate)
|
return filter(self, predicate)
|
||||||
|
Loading…
Reference in New Issue
Block a user