Software /
code /
prosody
Changeset
3392:6e31b49c4ab8
util.iterators: Add skip() to skip the first n items of an iterator
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 20 Jul 2010 12:37:28 +0100 |
parents | 3391:8ac3f60af3c4 |
children | 3393:5b8de0731c4d |
files | util/iterators.lua |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/iterators.lua Sun Jul 18 17:50:38 2010 +0500 +++ b/util/iterators.lua Tue Jul 20 12:37:28 2010 +0100 @@ -90,6 +90,15 @@ end, s; end +-- Skip the first n items an iterator returns +function skip(n, f, s, var) + for i=1,n do + var = f(s, var); + end + return f, s, var; +end + +-- Return the last n items an iterator returns function tail(n, f, s, var) local results, count = {}, 0; while true do