New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua: vim.func functional utils #28449
Comments
I don't think this is true. I would implement currying as this: local function curry(fn, ...)
local n, args = select('#', ...), { ... }
return function(...)
local fargs = {}
for i = 1, n do
fargs[i] = args[i]
end
for i = 1, select('#', ...) do
fargs[n+i] = select(i, ...)
end
return fn(unpack(fargs, 1, n + n2)
end
end
local curried = curry(f, 1, 2, 3, 4, nil, nil)
curried(5, 6, 7, nil)
-- equiv to:
-- f(1, 2, 3, 4, nil, nil, 5, 6, 7, nil) |
Is that currying or partial application? https://stackoverflow.com/a/218055/152142 |
Ah yeah, it's creating a partial, which is what you usually want. I'm sure the same concept can be used to create a currying function. |
Problem
This issue tracks some known functions that we want in
vim.func
.Related:
vim.iter
#23233Expected behavior
from #8677 (comment) :
but see also the caveats mentioned herecounterpoint)The text was updated successfully, but these errors were encountered: