This brings us to part six of Reducing Enumerable where we return to Scarlet for Red’s final lesson.
Table of Contents
- The Journey Begins
- Chartreuse — The Master of Map
- Indigo — The Master of Select
- Violet — The Master of Find
- Cerulean — The Master of Tally By
- A Final Lesson from Scarlet
On the Road Back
After saying farewell to Cerulean, and wishing him luck on his meeting with the council of 2.6, Red found himself back where it all started.
There again in the distance was the castle of his master, Scarlet. He had much to tell, and he was quite excited.
So Red told Scarlett of all the things he had learned and seen over the time he had spent in the land of Enumerable, and all the adventures he’d had.
He showed her all the functions he had learned, and told her of all the friends he had met along the way. It was truly an adventure of a life time, and he was glad to have taken it, but still he had a lingering question.
All he had done was implement functions which already existed. Was this all to say reduce should be used for everything, or…
Is reduce completely unnecessary?
A Lesson from Scarlet
“Ah Red, you’ve learned much, and of that I am quite proud. There is another lesson I must teach you though. Consider with me for a moment…” started Scarlet.
“…would you use an axe to trim a bonsai?” asked Scarlet.
“Well, no, that would be rather silly wouldn’t it?” questioned Red.
“Another thought…” she started.
“Would you use trimmers to cut down a mighty redwood?” she asked.
“Oh! Oh! Does this mean I get a git pruning?” asked Master Branch.
“Hush, you.” replied Scarlet under her breath.
“Well that wouldn’t make much sense either.” answered Red.
“So too are the ways of reduce! It has its uses when simple functions won’t do, but that doesn’t quite answer your question. Let us see some of the true powers of reduce.” answered Scarlet.
The Powers of Reduce
“There is true power here, young one, but power we must learn to use properly before we are able to use it correctly.” said Scarlet.
“There are arts of composition, currying, closures, transducers, category theories, and more beyond your wildest imaginations. That’s precisely what makes reduce so much fun to use and learn!” exclaimed Scarlet.
Consider that we could combine the ideas of selecting and mapping into one using reduce. So too we can take this idea further by combining any of the functions which can be implemented in terms of reduce.
The true power of reduce is in its flexibility to perform any Enumerable task, whether one or many. This leads into much more advanced arts.
“But you have journeyed far, and learned much. These are lessons for another day, for our time here is coming to a close dear Red. We shall talk again soon, and when that day comes I look forward to seeing everything you’ve done with what you’ve learned out there in the world.”
…and with that Red journeyed back home.
Red had much to think on from this, realizing how much there was yet to learn out in the world, and how amazing it was that even learning all he did today there was still so much more! It was a grand adventure, and he was glad that he took it.
For you see, my esteemed audience, that is the beauty of programming, there are always more mysteries to solve, lessons to learn, people to laugh with, friends to make, and journeys that need to be experienced.
Perhaps this is the end of Red’s story, or perhaps just the beginning of an even grander one in the land of Enumerable.
Credit where credit is due, you may have noticed a few easter eggs hiding around the presentation.
The first on our list are the foxes from Why the Lucky Stiff. His book was my first experience to Ruby, and in many ways shaped my love for whimsy. It would be rude not to give a tip of the hat to our dear old friend, no matter where life may have taken him now, let him know we are grateful for his presence no matter how brief.
Matz and DHH had given me permission in the original talk to use their likenesses as a bit of extra fun, so I’d like to thank them for being incredibly good sports about it.
I’d also snuck a bundler tape gun in, and a bit of thanks goes to Andre for allowing me to use it.
There are many more references and tricks I’ve hidden about, see if you can find them all!
On Reducing Enumerable
“Reducing Enumerable” is the culmination of half a years work, over 200 hours, 50 illustrations, 5000 lemur stickers, 1 5'5" lemur cutout, and a whole lot of love from an amazing community.
I couldn’t have pulled it off without all of your support, so know I’m thankful to every one of you who encouraged me along the way in preparing this material.
I’ve published an article exploring the Southeast Ruby version of the talk and some of the work that went into it:
Creating “Reducing Enumerable — An Illustrated Adventure”
How I created and illustrated my conference talk for Southeast Ruby 2018 (Video coming soon)
Both the Southeast Ruby and RubyConf versions of this talk should have their videos published within the next month, look forward to seeing them when they come out! I’ll post updates on twitter @keystonelemur and update these articles and the source repo once I see them:
Talk examples, articles, and other useful tidbits. Contribute to baweaver/reducing_enumerable development by creating…
It’s been a blast, and thank you again to everyone involved in this crazy project. Look forward to my next projects which I’ll be officially announcing soon!