Étude 7-4: Using lists:split/2

Use erl -man lists to see how the lists:split/2 function works, or try the following example and see if you can figure it out. Experiment to see what happens if the first argument is zero.

1> lists:split(4, [110, 220, 330, 440, 550, 660]).
{[110,220,330,440],[550,660]}

Use lists:split/2 and lists:foldl/3 to rewrite the dates:julian/1 function from Étude 6-3. Hint: you’ll use those functions when calculating the total number of days up to (but not including) the month in question.

See a suggested solution in Appendix A.

Get Études for Erlang now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.