Skip to content

Instantly share code, notes, and snippets.

@donkaban
Created October 18, 2014 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donkaban/727a174139591ceb65ae to your computer and use it in GitHub Desktop.
Save donkaban/727a174139591ceb65ae to your computer and use it in GitHub Desktop.
lua coillect
function collect(...)
local args = {...}
local numArgs = #args
local lambda = args[numArgs]
local result = {}
local finisher = 1
if(numArgs < 2) then Log.error("[QP] You must have minimum 2 params in collect()") return end
for i=1,numArgs-1 do
args[i](function(...)
if(#{...})==1 then
result[i] = ...
else
result[i] = {...}
end
finisher = finisher + 1
if(finisher == numArgs) then
lambda(unpack(result))
end
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment