Uploads from Xah Lee

Watch and track your favorite playlist.

Curated by: Xah Lee (847 videos)


Currently Playing: Xah Ep706 Fold and Reduce, in Wolfram Language, Emacs Lisp, JavaScript

Video Summary (AI Generated, Reviewed by Human) This video explains fold (also known as reduce) in functional programming. The creator highlights that fold/reduce is a general way to represent any loop you would typically use in imperative languages (2:25, 9:54, 11:13, 34:21). Here's a breakdown of the key points: • Purpose: Unlike map, which is limited, fold (or reduce) can handle more complex loop scenarios, especially when you need to maintain a "state" or track indices (7:17, 8:01, 11:01, 13:46). • Mechanism: It takes an initial value (the starting "state") and a function that processes each item from a list along with the accumulated "state" from the previous iteration (8:50, 9:12, 19:30, 20:20, 1:05:08). • Demonstrations: The video shows examples of fold in Wolfram Language (17:30) and reduce in JavaScript (22:29) and Emacs Lisp (28:47). • Terminology: The creator discusses why some languages use "fold" and others use "reduce." Historically, both terms come from theoretical computer science (33:36). • Some languages even have both, with "fold" typically taking an initial value and "reduce" not (36:02, 38:09). • The creator argues "fold" is a better term because "reduce" can be misleading, implying only a "many-to-one" transformation rather than a general loop (40:10, 1:04:17). • Parallel Computation: The video clarifies that fold/reduce itself is inherently sequential and not parallel. • However, if the operation used within the fold/reduce has commutative (order of arguments doesn't matter, e.g., a+b = b+a) and associative (grouping of operations doesn't matter, e.g., (a+b)+c = a+(b+c)) properties, then the computation can be done in parallel (41:56, 45:00, 50:59, 55:05). • The creator criticizes Google's "MapReduce" for misleading people into thinking reduce inherently means parallelism (58:48). Notes at http ://xahlee .info/talk_show/xah_talk_show_ep706.html Copy the link, remove spaces, paste the link in browser tab. Google Chrome and Firefox browsers censor websites by auto adding s in http and says the site Secure Connection Failed. Use Brave Browser or Safari.


Tracks in this Playlist

✅ Progress Tracking

Automatically track which videos you have watched. Your completion status is updated at a glance, preventing you from re-watching episodes by mistake.

⏯️ Resume Playback

Never lose your spot. Our custom player remembers your exact video and timestamp, allowing you to dive right back in seamlessly.

📱 Cross-Device Sync

Sync your playlist states, watched progress, and premium preferences across your desktop, laptop, tablet, and mobile phone automatically.

Start Organizing Your YouTube Playlists

Simply paste any YouTube playlist URL or channel link in the application search bar to immediately generate a custom, sorted, and progress-tracked workspace. No registration required to start.

Explore Playlist Guides & How-Tos