Fandom

Narutopedia

Module:Arrays

6,213pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

local p = {}
 
function p.removeDuplicates(frame)
	local arg, hash = frame:getParent().args[1], {}
	local m, n = mw.text.split(arg, ","), {}
 
	for _, l in ipairs(m) do
	    l = mw.text.trim(l)
        if (not hash[l]) then
            n[#n+1] = l
            hash[l] = true
        end
    end
 
    arg = table.concat(n, ", ")
	return arg
end
 
function p.removeCustom(frame)
	local args, hash = frame:getParent().args, {}
	if (args[1] == nil) then return '' end
	local t = mw.text.split(args[1], ",")
	local s = mw.text.split(args[2], ",")
 
    for i, v in ipairs(t) do
        t[i] = mw.text.trim(v)
        hash[t[i]] = true
    end
 
    if args[3] == '' then args[3] = false end
    if args[3] and not hash[args[3]] then return table.concat(t, ", ") end
 
    for i, v in ipairs(s) do
        s[i] = mw.text.trim(v)
    end
 
	for j = #s, 1, -1 do
    	for i = #t, 1, -1 do
            if t[i] == s[j] then
                table.remove(t, i)
            end 
        end 
    end
    return table.concat(t, ", ")
end
 
return p

Also on Fandom

Random Wiki