This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
bjornir90's profile picture

[Question] [parallel] how to run unknow number of functions

Started by bjornir90, 07 December 2012 - 08:33 AM
bjornir90 #1
Posted 07 December 2012 - 09:33 AM
Hello all !
So I have a table with all the functions in it, and I want to use parallel.waitforany() but has I don't how many functions there are in the table and I can't do a for loops because I want to run them together…. Is there any other ways than just checking how many functions are in the table and then do something like that ?


If #tableOfFunctions == 3 then
parallel.waitForAny(tableOfFunctions[1], tableOfFunctions[2], tableOfFunctions[3])
Elseif ...
And so ...
Thanks ! :)/>
Kingdaro #2
Posted 07 December 2012 - 09:41 AM
That, sir, is the power of unpack().


parallel.waitForAny(unpack(tableOfFunctions))
bjornir90 #3
Posted 07 December 2012 - 10:04 AM
That, sir, is the power of unpack().


parallel.waitForAny(unpack(tableOfFunctions))
Oh ok thanks you, don't know about that !! Will +1 if I was on my computer :P/>