A visual demo of Ruby's lazy enumerator
joyofrails.com
A visual demo of Ruby's lazy enumerator
1–10 of 28 posts
Re: A visual demo of Ruby's lazy enumerator
#2Re: A visual demo of Ruby's lazy enumerator
#3Nevertheless, this was great.
Re: A visual demo of Ruby's lazy enumerator
#4https://news.ycombinator.com/item?id=42652775 (different submitter; 29 points, 3 comments)
Re: A visual demo of Ruby's lazy enumerator
#5Excuse me while I go back through my code and make sure I’m using lazy enumeration wherever I’m iterating over large collections….
Re: A visual demo of Ruby's lazy enumerator
#6Some examples:
I wrote a utility gem a while ago that lets you lazily intersect, union, etc various potentially infinite streams of data. https://github.com/maxim/enum_utils/
I also used lazy enumeration for traversing the wordmap in my no-RAM static storage gem. https://github.com/maxim/wordmap/
Re: A visual demo of Ruby's lazy enumerator
#7I was expecting a visual comparison towards the end of the article, where you would be able to click a button and both the eager and lazy versions would start executing simultaneously, one displayed next to the other, and you would clearly see that the lazy one completed earlier. This would make it even more obvious how the lazy one is faster. Nevertheless, this was great.
There are probably a lot of fun variations to explore. Since this post seemed to resonate, I may be motivated to try some more experiments.
Re: A visual demo of Ruby's lazy enumerator
#8Really cool visualization and neat to learn about lazy enumeration! Excuse me while I go back through my code and make sure I’m using lazy enumeration wherever I’m iterating over large collections….
Re: A visual demo of Ruby's lazy enumerator
#9Re: A visual demo of Ruby's lazy enumerator
#10Lazy enumeration can also save memory, because you aren’t storing entire collections during intermediate steps, and it works with infinite/unknown size collections. Such as streaming data. Some examples: I wrote a utility gem a while ago that lets you lazily intersect, union, etc various potentially infinite streams of data. https://github.com/maxim/enum_utils/ I also used lazy enumeration for traversing the wordmap…