Mercurial > prosody-hg
comparison util/iterators.lua @ 5469:fcdcc37ffec1
Merge 0.9->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 12 Apr 2013 00:45:46 +0100 |
| parents | 2660407c3b73 |
| children | 167c1da54606 |
comparison
equal
deleted
inserted
replaced
| 5467:9b7c919bf238 | 5469:fcdcc37ffec1 |
|---|---|
| 120 return unpack(results[((count-1+pos)%n)+1]); | 120 return unpack(results[((count-1+pos)%n)+1]); |
| 121 end | 121 end |
| 122 --return reverse(head(n, reverse(f, s, var))); | 122 --return reverse(head(n, reverse(f, s, var))); |
| 123 end | 123 end |
| 124 | 124 |
| 125 local function _ripairs_iter(t, key) if key > 1 then return key-1, t[key-1]; end end | |
| 126 function it.ripairs(t) | |
| 127 return _ripairs_iter, t, #t+1; | |
| 128 end | |
| 129 | |
| 125 local function _range_iter(max, curr) if curr < max then return curr + 1; end end | 130 local function _range_iter(max, curr) if curr < max then return curr + 1; end end |
| 126 function it.range(x, y) | 131 function it.range(x, y) |
| 127 if not y then x, y = 1, x; end -- Default to 1..x if y not given | 132 if not y then x, y = 1, x; end -- Default to 1..x if y not given |
| 128 return _range_iter, y, x-1; | 133 return _range_iter, y, x-1; |
| 129 end | 134 end |
