Skip to content

aperezdc/lua-itertools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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