# HG changeset patch # User Matthew Wild # Date 1365723946 -3600 # Node ID fcdcc37ffec16a584b83ca5e1199a75afb4928cc # Parent 9b7c919bf238063ab3857729f88d2b61522080a7# Parent 2660407c3b736203d0f3b82ba4b15dbf8ab4b44c Merge 0.9->trunk diff -r 9b7c919bf238 -r fcdcc37ffec1 util/iterators.lua --- a/util/iterators.lua Fri Apr 12 00:32:10 2013 +0100 +++ b/util/iterators.lua Fri Apr 12 00:45:46 2013 +0100 @@ -122,6 +122,11 @@ --return reverse(head(n, reverse(f, s, var))); end +local function _ripairs_iter(t, key) if key > 1 then return key-1, t[key-1]; end end +function it.ripairs(t) + return _ripairs_iter, t, #t+1; +end + local function _range_iter(max, curr) if curr < max then return curr + 1; end end function it.range(x, y) if not y then x, y = 1, x; end -- Default to 1..x if y not given