Jump to content

Module:US elections imagemap/utils: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 4: Line 4:


function p.nowiki(str)
function p.nowiki(str)
return String2.nowiki({args = {str}})
return String2.nowiki({args = {str}}) -- I wish people would write functions for LUA, not for WIKIPEDIA, c'mon
end
end



Revision as of 04:43, 19 January 2021

local String2 = require("Module:String2")

local p = {}

function p.nowiki(str)
	return String2.nowiki({args = {str}}) -- I wish people would write functions for LUA, not for WIKIPEDIA, c'mon
end

function p.split(str, sep) -- split string by separator and return table
  sep = sep or "%s"
  local parts = {}
  for word in string.gmatch(str, "[^" .. sep .. "]+") do parts[#parts+1] = p.nowiki(word) end
  return parts
end

function p.listmerge(t1, t2) -- only works on tables that are lists, not dictionaries
	for i, j in ipairs(t2) do
		table.insert(t1, j)
	end
	return t1
end

return p