mirror of https://github.com/attractivechaos/klib
added table.shuffle()
This commit is contained in:
parent
1f2ef7afd5
commit
54004e39cf
|
@ -39,6 +39,7 @@
|
|||
string:split()
|
||||
io.xopen()
|
||||
table.ksmall()
|
||||
table.shuffle()
|
||||
math.lgamma() >math.lbinom() >math.igamma()
|
||||
math.igamma() <math.lgamma() >matrix.chi2()
|
||||
math.erfc()
|
||||
|
@ -163,6 +164,13 @@ function table.ksmall(arr, k)
|
|||
end
|
||||
end
|
||||
|
||||
function table.shuffle(a)
|
||||
for i = #a, 1, -1 do
|
||||
local j = math.random(i)
|
||||
a[j], a[i] = a[i], a[j]
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Mathematics
|
||||
--
|
||||
|
|
Loading…
Reference in New Issue