Moduł:Shuffle: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Ostrzyciel (dyskusja • edycje) M (klej) |
Ostrzyciel (dyskusja • edycje) M |
||
Linia 12: | Linia 12: | ||
function p.shuffle(frame) |
function p.shuffle(frame) |
||
t = shuffleArr(frame:getParent().args) |
local t = shuffleArr(frame:getParent().args) |
||
s = "" |
local s = "" |
||
for _,arg in pairs(t) do |
for _,arg in pairs(t) do |
||
s = s .. arg .. "\n" |
s = s .. arg .. "\n" |
Wersja z 23:43, 11 maj 2019
local p = {}
local function shuffleArr(t)
local n = #t
while n > 1 do
local k = math.random(n)
t[n], t[k] = t[k], t[n]
n = n - 1
end
return t
end
function p.shuffle(frame)
local t = shuffleArr(frame:getParent().args)
local s = ""
for _,arg in pairs(t) do
s = s .. arg .. "\n"
end
return s
end
return p