aboutsummaryrefslogblamecommitdiffstats
path: root/test/integration/beam/library.erl
blob: b9186ab7e8a0b7a80c769c9dfacdfc4146756932 (plain) (tree)


















                                                                                              
-module(library).
-export([books/0]).

books() ->
    from([book(<<"Structure and Interpretation of Computer Programs">>, <<"Harold Abelson">>),
          book(<<"The Art of Computer Programming">>, <<"Donald Knuth">>),
          book(<<"An Introduction to Database Systems">>, <<"C. J. Date">>),
          book(<<"Less Than Words Can Say">>, <<"Richard Mitchell">>),
          book(<<"The Graves of Academe">>, <<"Richard Mitchell">>),
          book(<<"The Leaning Tower of Babel">>, <<"Richard Mitchell">>),
          book(<<"The Gift of Fire">>, <<"Richard Mitchell">>)]).

book(Title, Author) -> {<<"book">>, #{<<"title">> => Title, <<"author">> => Author}}.

from(Books) ->
    fun(Limit) ->
        {Now, Later} = lists:split(min(Limit, length(Books)), Books),
        {Now, case Later of [] -> done; _ -> from(Later) end}
    end.