Release: Bug Fixes and Improvements (#399)
fix: Error messages and run all tests (#381) feat: Automatically open fold under cursor (#380) fix: Discussion ID is not required (#383) chore: Add more emojis (#384) fix: Publish all drafts (#391) fix: Make discussion tree buffers no-modifiable (#394) fix: Incorrect warning about commits (#395) fix: Show draft replies in the correct tree (#396) fix: Cannot choose merge requests (#398) --------- Co-authored-by: George Kontridze <george.kontridze@gmail.com> Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me>
This commit is contained in:
committed by
GitHub
parent
38bde8a0e4
commit
341d56a1cb
@@ -33,6 +33,23 @@ function List:filter(func)
|
||||
return result
|
||||
end
|
||||
|
||||
---Partitions a given list into two lists
|
||||
---@generic T
|
||||
---@param func fun(v: T, i: integer):boolean
|
||||
---@return List<T>, List<T> @Returns two lists: the 1st with elements for which func returns true, the 2nd with elements for which it returns false
|
||||
function List:partition(func)
|
||||
local result_true = List.new()
|
||||
local result_false = List.new()
|
||||
for i, v in ipairs(self) do
|
||||
if func(v, i) == true then
|
||||
table.insert(result_true, v)
|
||||
else
|
||||
table.insert(result_false, v)
|
||||
end
|
||||
end
|
||||
return result_true, result_false
|
||||
end
|
||||
|
||||
function List:reduce(func, agg)
|
||||
for i, v in ipairs(self) do
|
||||
agg = func(agg, v, i)
|
||||
|
||||
Reference in New Issue
Block a user