Skip to content

aperezdc/lua-itertools

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

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

Stars

Watchers

Forks

Packages

No packages published