Use original keys for where
This commit is contained in:
parent
0057655465
commit
b57d52a2ae
1 changed files with 3 additions and 6 deletions
|
|
@ -153,21 +153,18 @@ end
|
||||||
---@return F|{ [K]: V }
|
---@return F|{ [K]: V }
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function f:where(func)
|
function f:where(func)
|
||||||
local i = 0
|
|
||||||
|
|
||||||
return f.new(function()
|
return f.new(function()
|
||||||
local k, v
|
local k, v
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
k, v = self:next()
|
k, v = self:next()
|
||||||
|
|
||||||
if k == nil then
|
if k ~= nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if func(v, k) then
|
if func(v, k) then
|
||||||
i = i + 1
|
return k, v
|
||||||
return i, v
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -416,7 +413,7 @@ return function(tbl, fpairs, step)
|
||||||
local stop = not fpairs and tbl or
|
local stop = not fpairs and tbl or
|
||||||
(type(fpairs) == "number") and fpairs or error("Invalid argument type for 'fpairs': " .. type(fpairs))
|
(type(fpairs) == "number") and fpairs or error("Invalid argument type for 'fpairs': " .. type(fpairs))
|
||||||
|
|
||||||
if step ~= 0 and ((step < 0) == (start < stop)) then
|
if step and step ~= 0 and ((step < 0) == (start < stop)) then
|
||||||
return none
|
return none
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue