Module:RepeatString

-- This module provides a method to repeat a string an arbitrary number of times.

Module = {};

Module.RepeatString = function( frame )

local theString  = frame.args[1] local stringCount = tonumber(frame.args[2])

if theString == nil then return "Error: No string specified." elseif stringCount == nil then return "Error: No count specified." end

-- Initialize a table. More memory-efficient than string concatenation; -- see "Concatenation operator" in the Scribunto Lua reference manual. local result = {} local repeats = 0

while ( repeats <= stringCount ) do       result[repeats] = theString repeats = repeats + 1 end

return table.concat( result )

end

return Module