1
0
forked from osmarks/potatOS

string * function multiplication

This commit is contained in:
2020-08-31 15:58:07 +01:00
parent 3998cbde6a
commit 6a3dc8e774
2 changed files with 9 additions and 3 deletions

View File

@@ -1324,7 +1324,13 @@ define_operation(string_mt, "__mul", function (a, b)
for _, v in pairs(b) do
table.insert(z, tostring(v))
end
return table.concat(z, a)
return table.concat(z, a)
elseif type(b) == "function" then
local out = {}
for i = 1, #a do
table.insert(out, b(a:sub(i, i)))
end
return table.concat(out)
else
return a
end