util.iterators: Normalize indentation

This commit is contained in:
Kim Alvefur 2016-04-13 20:00:41 +02:00
parent 131f28affd
commit 4bacbb7d71

View file

@ -23,18 +23,18 @@ function it.reverse(f, s, var)
while true do while true do
local ret = { f(s, var) }; local ret = { f(s, var) };
var = ret[1]; var = ret[1];
if var == nil then break; end if var == nil then break; end
t_insert(results, 1, ret); t_insert(results, 1, ret);
end end
-- Then return our reverse one -- Then return our reverse one
local i,max = 0, #results; local i,max = 0, #results;
return function (_results) return function (_results)
if i<max then if i<max then
i = i + 1; i = i + 1;
return unpack(_results[i]); return unpack(_results[i]);
end end
end, results; end, results;
end end
-- Iterate only over keys in a table -- Iterate only over keys in a table
@ -62,8 +62,8 @@ function it.unique(f, s, var)
while true do while true do
local ret = pack(f(s, var)); local ret = pack(f(s, var));
var = ret[1]; var = ret[1];
if var == nil then break; end if var == nil then break; end
if not set[var] then if not set[var] then
set[var] = true; set[var] = true;
return unpack(ret, 1, ret.n); return unpack(ret, 1, ret.n);
end end
@ -77,7 +77,7 @@ function it.count(f, s, var)
while true do while true do
var = f(s, var); var = f(s, var);
if var == nil then break; end if var == nil then break; end
x = x + 1; x = x + 1;
end end
@ -110,7 +110,7 @@ function it.tail(n, f, s, var)
while true do while true do
local ret = pack(f(s, var)); local ret = pack(f(s, var));
var = ret[1]; var = ret[1];
if var == nil then break; end if var == nil then break; end
results[(count%n)+1] = ret; results[(count%n)+1] = ret;
count = count + 1; count = count + 1;
end end
@ -157,7 +157,7 @@ function it.to_array(f, s, var)
local t = {}; local t = {};
while true do while true do
var = f(s, var); var = f(s, var);
if var == nil then break; end if var == nil then break; end
t_insert(t, var); t_insert(t, var);
end end
return t; return t;
@ -169,7 +169,7 @@ function it.to_table(f, s, var)
local t, var2 = {}; local t, var2 = {};
while true do while true do
var, var2 = f(s, var); var, var2 = f(s, var);
if var == nil then break; end if var == nil then break; end
t[var] = var2; t[var] = var2;
end end
return t; return t;