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)
frame = {args = {}}
frame.args[1] = str
frame.args[1] = str
return nowiki(frame)
return nowiki(frame)

Revision as of 04:42, 19 January 2021

local String2 = require("Module:String2")

local p = {}

function p.nowiki(str)
	frame = {args = {}}
	frame.args[1] = str
	return nowiki(frame)
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