From e5d07c158f99a78a1e69c4ad2ffc297e2c6d4dea Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:48:53 +0000 Subject: util.iterators: Don't replace var, as we should preserve var from the original iterator [luacheck] --- util/iterators.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/iterators.lua') diff --git a/util/iterators.lua b/util/iterators.lua index 868ba786..92f75189 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -154,7 +154,7 @@ end -- Convert the values returned by an iterator to an array function it.to_array(f, s, var) - local t, var = {}; + local t = {}; while true do var = f(s, var); if var == nil then break; end -- cgit v1.2.3 From e2f3356e2404641840283b8d439137e58604346b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:49:46 +0000 Subject: util.iterators: Return initial var from upstream iterator [luacheck] --- util/iterators.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/iterators.lua') diff --git a/util/iterators.lua b/util/iterators.lua index 92f75189..99b5f090 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -93,7 +93,7 @@ function it.head(n, f, s, var) end c = c + 1; return f(s, var); - end, s; + end, s, var; end -- Skip the first n items an iterator returns -- cgit v1.2.3 From cae49b6891841ba8458733bc2f364c0fd89e48b7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:52:57 +0000 Subject: util.iterators: Variable renaming to avoid shadowing [luacheck] --- util/iterators.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'util/iterators.lua') diff --git a/util/iterators.lua b/util/iterators.lua index 99b5f090..d453a694 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -29,10 +29,10 @@ function it.reverse(f, s, var) -- Then return our reverse one local i,max = 0, #results; - return function (results) + return function (_results) if i= n then return nil; end c = c + 1; - return f(s, var); + return f(_s, _var); end, s, var; end -- Skip the first n items an iterator returns function it.skip(n, f, s, var) - for i=1,n do + for _ = 1, n do var = f(s, var); end return f, s, var; @@ -132,9 +132,9 @@ function it.filter(filter, f, s, var) local filter_value = filter; function filter(x) return x ~= filter_value; end end - return function (s, var) + return function (_s, _var) local ret; - repeat ret = pack(f(s, var)); + repeat ret = pack(f(_s, _var)); var = ret[1]; until var == nil or filter(unpack(ret, 1, ret.n)); return unpack(ret, 1, ret.n); -- cgit v1.2.3