Skip to content
DevMeme
6213 of 7590
FunctionalProgramming Post #6811 · source on Telegram

Map, filter, reduce - the entire digestive pipeline in one snippet

Description

The meme shows a dark-theme code editor screenshot with three separate functional calls written in a JavaScript-flavored syntax and illustrated entirely with emojis. 1) “map([🐄, 🍠, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿]” converts raw ingredients (cow, sweet potato, chicken, corn) into cooked fast-food items. 2) “filter([🍔, 🍟, 🍗, 🍿], isVegetarian) => [🍟, 🍿]” removes the meat, leaving fries and popcorn. 3) “reduce([🍔, 🍟, 🍗, 🍿], eat) => 💩” collapses the array down to a single poop emoji, humorously modelling human digestion. Visually the code is white on a charcoal background with array brackets, commas, and arrow function notation, perfectly mimicking actual JavaScript while poking fun at functional pipelines and the inevitability of side-effects

Comments

9
Anonymous ★ Top Pick Even in pure functional land, reduce eventually yields a non-idempotent side effect - ask your garbage collector
  1. Anonymous ★ Top Pick

    Even in pure functional land, reduce eventually yields a non-idempotent side effect - ask your garbage collector

  2. Anonymous

    After 20 years of explaining monads, we've finally achieved peak functional programming pedagogy: using poop emojis to demonstrate reduce(). At least it's more honest than pretending our production code is as pure as our conference talks

  3. Anonymous

    This is the most accurate visualization of reduce() I've ever seen - it perfectly captures how we take a beautiful collection of discrete values and collapse them into something far less elegant. Though in production, that final output usually represents our technical debt rather than biological necessity

  4. Anonymous

    Beautiful functional composition: map and filter compose cleanly, then a left fold over real-world inputs still converges to the universal production monoid - 💩

  5. Anonymous

    Map and filter are pure; choose 'eat' as your reducer and you’ve perfectly modeled enterprise dataflow - beautiful composition that deterministically folds into a well-typed pile of 💩

  6. Anonymous

    FP purity holds until reduce(eat) - the ultimate side effect no monad can bind

  7. @spacenuke 1y

    Ruby does this, heck even PHP does this. As far as I can tell the only real “thing” about pure functional languages is that they extend a single statement as long as is needed to encompass what it must do, instead of using a lot of temporary variables

  8. @spacenuke 1y

    But the latter are easier for people to think about, and the compilers for them are better anyway

  9. bur del lago 1y

    this is a very functional introduction

Use J and K for navigation