Advertisement
Rochet2

Untitled

Feb 14th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.32 KB | None | 0 0
  1. T = {
  2. }
  3. T[10] = 99
  4. T[1] = 65
  5. T[5] = 58
  6.  
  7. function table.first(T)
  8.     -- return pairs(T)(T) -- doesnt work properly, returns 10, 99
  9.     for i = 1, table.maxn(T) do if(T[i]) then return i, T[i] end end
  10. end
  11. function table.last(T)
  12.     return table.maxn(T), T[table.maxn(T)]
  13. end
  14.  
  15. print(table.first(T))
  16. print(table.last(T))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement