Created
October 18, 2014 00:05
-
-
Save donkaban/727a174139591ceb65ae to your computer and use it in GitHub Desktop.
lua coillect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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