Erlang lazy list library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixed zlist_st to map Dec 13, 2016
test Implemented zlist with state: zlist_st Sep 30, 2016
.gitignore Init Feb 28, 2016
.travis.yml Get rid of r17 in .travis.yml Dec 27, 2016
LICENSE Init Feb 28, 2016 Updated Dec 27, 2016
rebar.config Better coveralls script Apr 20, 2016
rebar.config.script Better coveralls script Apr 20, 2016
rebar.lock Fixed Sep 27, 2016

Build Status Coveralls GitHub tag

Erlang zlist: a lazy sequences library.


Unlike zlist() is a function that returns improper list with data and next zlist or an empty list. You can use it to organize lazy evolution or backpressure.

Simple infinite iterator:

1> SimpleZ = fun Loop() -> [1|Loop] end.

2> zlist:take(10, SimpleZ).


Integrate to your project

This is a rebar'ized project, so, if you are already using rebar, just insert a reference to this git repo at your rebar.config.


1> Z = zlist:recurrent(fun(A) -> A + 1 end, 0).

2> zlist:take(10, Z).

3> Z2 = zlist:map(fun(A) -> A * 2 end, Z).

4> zlist:take(10, Z2).

5> ZL = zlist:from_list([1,2,5]).

6> zlist:to_list(ZL).

7> ZR = zlist:ciclyc(ZL).

8> zlist:take(10, ZR).

9> Z3 = zlist:flatmap(fun(A) -> zlist:from_list([-A, A]) end, Z2).

10> zlist:take(10, Z3).

Warnings !!!

With zlist you are working with potentially infinite data. Don't use to_list/1, foreach/2, fold/3 functions until you know that zlist is finite state. Use dropwhen/1 before, or take/2 instead.