Advertisement
JiiCeii

table.lua

Mar 9th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. local table = {}
  2.  
  3. function Table(t)
  4.     return setmetatable(t, table)
  5. end
  6.  
  7. function table:len()
  8.     local n = 0
  9.     while(self[n+1]) do
  10.         n = n+1
  11.     end
  12.     return n
  13. end
  14.  
  15. function table:concat(c)
  16.     local str = ""
  17.     for i = 1, self:len() do
  18.         str = str .. (c or "") .. self[i]
  19.     end
  20.     return str:sub((c or ""):len()+1)
  21. end
  22.  
  23. function table:insert(v, i)
  24.     self[(i or self:len()+1)] = v
  25. end
  26.  
  27.  
  28. function table:remove(v)
  29.     --TODO
  30. end
  31.  
  32. table.__index = table
  33.  
  34. t = Table{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement