View Single Post
11/02/15, 09:45 AM   #12
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by @AlphaLemming View Post
I will try it this way (not yet tested):
Lua Code:
  1. for x, name in pairs(namedata) do
  2.         for y, base in pairs(basedata) do
  3.             if name == base then table.remove(namedata,x); table.remove(basedata,y); break end
  4.         end
  5.     end
  6. end
This won't work because table.remove shifts indices, and you will skip the next value (edit: removed incorrect info; you can delete table values during traversal). Anyway you don't need 2 nested loops. Assuming the 0-level name has fewer words, you can:
Lua Code:
  1. local i = #basedata
  2. for j = #namedata, 1, -1 do
  3.     if namedata[j] == basedata[i] then
  4.         table.remove(namedata, j)
  5.         i = i - 1
  6.     end
  7. end

Last edited by merlight : 11/05/15 at 05:49 AM.
  Reply With Quote