Jump to content

Module:US elections imagemap/utils

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Elli (talk | contribs) at 04:31, 19 January 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

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] = 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
		t1.insert(j)
	end
	return t1
end

return p