Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

Functional iterators for Lua based on coroutines

Resources

Packages

No packages published
You can’t perform that action at this time.