Jump to content

Module:OutputBuffer: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Jackmcbarn (talk | contribs)
make a printf-like too
Jackmcbarn (talk | contribs)
change output order and fix bug
Line 1: Line 1:
return function()
return function()
local buffer = {}
local buffer = {}
return function(text)
return function(sep)
local b = buffer
buffer = {}
return table.concat(b, sep)
end,
function(text)
buffer[#buffer + 1] = text
buffer[#buffer + 1] = text
end,
end,
function(...)
function(...)
buffer[#buffer + 1] = string.format(...)
buffer[#buffer + 1] = string.format(...)
end,
function(sep)
local b = buffer
buffer = nil
return table.concat(b, sep)
end
end
end
end

Revision as of 00:06, 26 June 2014

return function()
	local buffer = {}
	return function(sep)
		local b = buffer
		buffer = {}
		return table.concat(b, sep)
	end,
	function(text)
		buffer[#buffer + 1] = text
	end,
	function(...)
		buffer[#buffer + 1] = string.format(...)
	end
end