Advertisement
Daraketh

tableLookUpV2

Jun 13th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. --~ print a table
  2. function printTable(list, i)
  3.  
  4.     local listString = ''
  5. --~ begin of the list so write the {
  6.     if not i then
  7.         listString = listString .. '{'
  8.     end
  9.  
  10.     i = i or 1
  11.     local element = list[i]
  12.  
  13. --~ it may be the end of the list
  14.     if not element then
  15.         return listString .. '}'
  16.     end
  17. --~ if the element is a list too call it recursively
  18.     if(type(element) == 'table') then
  19.         listString = listString .. printTable(element)
  20.     else
  21.         listString = listString .. element
  22.     end
  23.  
  24.     return listString .. ', ' .. printTable(list, i + 1)
  25.  
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement