Moduł:Shuffle: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Ostrzyciel (dyskusja • edycje) M |
Ostrzyciel (dyskusja • edycje) M |
||
Linia 1: | Linia 1: | ||
local p = {} |
local p = {} |
||
local function deepcopy(orig) |
|||
local orig_type = type(orig) |
|||
local copy |
|||
if orig_type == 'table' then |
|||
copy = {} |
|||
for orig_key, orig_value in next, orig, nil do |
|||
copy[deepcopy(orig_key)] = deepcopy(orig_value) |
|||
end |
|||
setmetatable(copy, deepcopy(getmetatable(orig))) |
|||
else -- number, string, boolean, etc |
|||
copy = orig |
|||
⚫ | |||
return copy |
|||
end |
|||
function p.shuffle(frame) |
function p.shuffle(frame) |
||
math.randomseed(os.time()) |
math.randomseed(os.time()) |
||
for _,arg in pairs(frame:getParent().args) do |
|||
local t = {"a", "b", "c", "d"} |
|||
table.insert(t, arg) |
|||
⚫ | |||
local s = "" |
local s = "" |
||
while #t > 0 do |
while #t > 0 do |