17,105
edits
(Implement joinList()) |
m (joinList: Minor optimisation) |
||
Line 372: | Line 372: | ||
-- for the last two elements | -- for the last two elements | ||
function p.joinList(list, sep, lastSep) | function p.joinList(list, sep, lastSep) | ||
if lastSep ~= nil and #list > 1 then | if lastSep ~= nil and sep ~= lastSep and #list > 1 then | ||
return string.sub(table.concat(list, sep), 1, -(1 + string.len(sep) + string.len(list[#list]))) .. lastSep .. list[#list] | return string.sub(table.concat(list, sep), 1, -(1 + string.len(sep) + string.len(list[#list]))) .. lastSep .. list[#list] | ||
else | else |