Moduł:Shuffle: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Ostrzyciel (dyskusja • edycje) M (paaanie idź pan w ch) |
Ostrzyciel (dyskusja • edycje) M |
||
Linia 1: | Linia 1: | ||
local p = {} |
local p = {} |
||
local function shuffleArr(t) |
|||
math.randomseed(os.time()) |
|||
⚫ | |||
while n > 1 do |
|||
⚫ | |||
t[n], t[k] = t[k], t[n] |
|||
⚫ | |||
end |
|||
return t |
|||
end |
|||
function p.shuffle(frame) |
function p.shuffle(frame) |
||
local t = frame:getParent().args |
local t = shuffleArr(frame:getParent().args) |
||
local s = "" |
local s = "" |
||
⚫ | |||
for _,arg in pairs(t) do |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Wersja z 23:55, 11 maj 2019
local p = {}
local function shuffleArr(t)
math.randomseed(os.time())
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