Lazy - fun project exploring lazy sequences in Erlang

Yeah, I feel the same when it comes to the pipe operator :wink:

So yes, this was just a fun project to see if and how we could pull it off, and as we got in the swing of it, we added function after function, which was a drag to test and document afterwards :blush: But it turned out quite nice IMO and so we decided to show it off here :sweat_smile: It might even be useful to someone.

What surprised me was that both libraries have a lot of the functions in common, often with the same or at least similar names even. Did you model it on and take inspiration from the lists module? At least this is what we did :wink:

Personally, I’m a bit torn on the topic of lazy evaluation, and lazy sequences in particular. They are quite cool, but somewhat less predictable than non-lazy ones, more so if you allow for infinite sequences. You might go chugging along nice and lazy, taking the low memory usage for granted and all, and suddenly through some lapse it may explode into memory all at once, or you end up in an infinite loop as you run down an infinite sequence.

I think Erlang is wise not to have laziness built in into lists like other languages do (or maybe that wasn’t a conscious decision). It’s predictable by default, but it does not block the way for implementations like ours (or Gleams), which you may use (or implement yourself) if you need it and hopefully understand the hidden risks.

3 Likes