Module:Array: Difference between revisionsGive feedback
Jump to navigation
Jump to search
osrsw>Talulah add some bugs. |
osrsw>Talulah m add take_from |
||
| Line 86: | Line 86: | ||
function p.reject(enum, fn) | function p.reject(enum, fn) | ||
local r = {} | local r = {} | ||
for | for index, item in ipairs(enum) do | ||
if not fn(item) then | if not fn(item, index) then | ||
table.insert(r, item) | table.insert(r, item) | ||
end | end | ||
| Line 177: | Line 177: | ||
end | end | ||
return r | return r | ||
end | |||
function p.take_from(enum, index, count) | |||
local x, _ = p.split(p.reject(enum, | |||
function(item, idx) | |||
return idx < index | |||
end | |||
), count) | |||
return x | |||
end | end | ||
return p | return p | ||
-- </nowiki> | -- </nowiki> | ||