Demonstrating map, filter, and reduce in Swift using food emoji

by Joey deVilla on June 26, 2016

In my last article, I posted this graphic, which uses emoji to make it easier to understand what the map, filter, and reduce functions do:

map filter reduce in emoji

Since then, I’ve been asked by a couple of friends if what’s in the graphic is just pseudocode or if it could actually be implemented. I told them it was the latter, and here’s my implementation in Swift:

I put this into a Swift playground, which you can copy from this Gist or download here.

Leave a Comment

{ 1 trackback }

Previous post:

Next post: