diff options
author | Kim Alvefur <zash@zash.se> | 2016-04-13 20:00:41 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-04-13 20:00:41 +0200 |
commit | c8b2b00c928e5922ab38929626155eb2a2cf8a05 (patch) | |
tree | f9c992ee74145687cf51be12db20e35a2f4d5227 | |
parent | 3d4f0aab4b33871d2c237ac2e7861021902f5b88 (diff) | |
download | prosody-c8b2b00c928e5922ab38929626155eb2a2cf8a05.tar.gz prosody-c8b2b00c928e5922ab38929626155eb2a2cf8a05.zip |
util.iterators: Normalize indentation
-rw-r--r-- | util/iterators.lua | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/util/iterators.lua b/util/iterators.lua index e553229e..5f03bd10 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -23,18 +23,18 @@ function it.reverse(f, s, var) while true do local ret = { f(s, var) }; var = ret[1]; - if var == nil then break; end + if var == nil then break; end t_insert(results, 1, ret); end -- Then return our reverse one local i,max = 0, #results; return function (_results) - if i<max then - i = i + 1; - return unpack(_results[i]); - end - end, results; + if i<max then + i = i + 1; + return unpack(_results[i]); + end + end, results; end -- Iterate only over keys in a table @@ -62,8 +62,8 @@ function it.unique(f, s, var) while true do local ret = pack(f(s, var)); var = ret[1]; - if var == nil then break; end - if not set[var] then + if var == nil then break; end + if not set[var] then set[var] = true; return unpack(ret, 1, ret.n); end @@ -77,7 +77,7 @@ function it.count(f, s, var) while true do var = f(s, var); - if var == nil then break; end + if var == nil then break; end x = x + 1; end @@ -110,7 +110,7 @@ function it.tail(n, f, s, var) while true do local ret = pack(f(s, var)); var = ret[1]; - if var == nil then break; end + if var == nil then break; end results[(count%n)+1] = ret; count = count + 1; end @@ -157,7 +157,7 @@ function it.to_array(f, s, var) local t = {}; while true do var = f(s, var); - if var == nil then break; end + if var == nil then break; end t_insert(t, var); end return t; @@ -169,7 +169,7 @@ function it.to_table(f, s, var) local t, var2 = {}; while true do var, var2 = f(s, var); - if var == nil then break; end + if var == nil then break; end t[var] = var2; end return t; |