ipairs refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-26 18:28:01 +01:00
parent 90d92ecc34
commit 3f3c7b28fc
9 changed files with 47 additions and 39 deletions
+3 -3
View File
@@ -97,10 +97,10 @@ end
function weighted_median(list)
sort(list, function(a,b) return a.value < b.value end)
local weight = 0
for _, element in ipairs(list) do
weight = weight + element.weight
for i = 1, getn(list) do
weight = weight + list[i].weight
if weight >= .5 then
return element.value
return list[i].value
end
end
end