Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are asking for something to call a list of functions, I just typed this very small module for you (if you can even call it that).</p> <pre><code>-- No guarantees whether this will work. function ExecFunc (fnctn,nTimes,Threaded,...) local to_call = function () fnctn(...) end for x = 1,nTimes do if Threaded then coroutine.resume(coroutine.create(to_call)) else to_call() end end end function ExecFuncs (Async,...) -- All parts of ... should be tables {function f, number t[, table args]} local funcInfo = {...} for _,funcThing in pairs(funcInfo) do local a = funcThing.args if a then ExecFunc(funcThing.f,funcThing.t,Async,unpack(a)) else ExecFunc(funcThing.f,funcThing.t,Async) end end end -- These don't check for argument validity, -- so you should either be careful with the arguments -- or call these in protected mode (with pcall). </code></pre> <p>If I wasted my time with that, it was fun anyway, but after typing it I reread your question... You want something to iterate through a list of functions and pass a random number to each one.</p> <pre><code>function ExecuteWithRandomValues (func_list,async) assert(type(func_list) == "table","Expected table.") local passbacks = {} local threads if async then threads = {} end for _,func in pairs(func_list) do assert(type(func) == "function","Value [" .. _ .. "] is not a function.") local toCall = function () local rnd = math.random(-math.huge,math.huge) local out = func(rnd) passbacks[_] = {input = rnd, output = out} end if async then table.insert(threads,coroutine.create(toCall)) else toCall() end end if async then for _,thread in pairs(threads) do coroutine.resume(thread) end for _,thread in pairs(threads) do while coroutine.status(thread) ~= "dead" do end end end return passbacks end -- Again, no guarantees this thing is free of errors. -- There are better ways to run and check the statuses -- of asynchronous threads, but this is fairly convenient. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload