lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> Okay... back to work... :)

Thanks for answering, it was an interesting brain puzzle.
Yes, it was perfect situation for using coroutine, as pointed also by 
Michal Kottman.

I've spent some time thinking about your answer… i think i get it.
You cannot use anonymous functions in this case, as you have to 
recursively call it.

Without «for» loop, it's quite easy (but no coroutines anymore)

function recur(t,mother)
   local k,v = next(t,k) --firt «next» call: k == nil
   while k do
      if type(v) == "table" then
         recur(v, k)
         print (mother,v)

      k,v = next(t,k)

I guess i must practice more before getting fluent in Lua !