Functional iterators for Lua based on coroutines
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
luarocks
spec
.busted
.gh-pages
.travis.yml
CHANGELOG.md
README.md
config.ld
itertools.lua

README.md

lua-itertools

Build Status Coverage Status Documentation

Example

-- Import the module.
local itertools = require "itertools"

-- Create an infinite iterator which produces numbers starting at 100
local iterable = itertools.count(100)

-- Filter (select) the numbers which are divisible by three.
iterable = itertools.filter(function (x) return x % 3 == 0 end, iterable)

-- Pick only 10 of the numbers.
iterable = itertools.islice(iterable, 1, 10)

-- Calculate the square of each number
iterable = itertools.map(function (x) return x * x end, iterable)

-- Print them using a for-loop.
for item in iterable do print(item) end