feat(libs): add utils.rep

This commit is contained in:
Guillaume ARM 2024-05-24 01:08:03 +02:00
parent f9fb8e26df
commit 3ef5930f4f

View File

@ -92,4 +92,18 @@ utils.find = function(t, predicate)
end
end
-- repeat n times the given element x in a new table
utils.rep = function(x, n)
if n < 1 then
return {}
end
local result = {}
for i=1, n, 1 do
result[i] = x
end
return result
end
return utils