"std::accumulate: Exploring an Algorithmic Empire"
summary
Claim: std::accumulate is the most powerful STL algorithm because any associative binary op plus an identity (a monoid) becomes parallelizable and composable. Examples: rendering a heterogeneous JSON via a variant-based fold, folding tuples into an ostream, and using optional as a sentinel to implement an unfold (pull/push) generator. C++17 reduce gives parallel semantics for associative ops. An experiment rewrites about 77 plain-loop algorithms in terms of accumulate, showing monoids everywhere and promoting fold/unfold as a general design pattern.
AI-written summary · about
chapters (10)
- 0:00Introduction to accumulate
- 1:49Accumulating Boolean values
- 5:20Monoids and their properties
- 9:54Why use accumulate over loops
- 15:31Accumulating multi-dimensional data
- 27:44Accumulating heterogeneous sequences
- 32:22Introducing unfold operation
- 39:12Main talk conclusion
- 39:32Algorithmic perversions postscript
- 46:37Conclusion and next steps
related talks
57mBuilding an Intuition for Composition
58mMonoids, Monads, and Applicative Functors: Repeated Software Patterns
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 03mMonads in Modern C++
01h 09mThe Definitive Guide to Functional Programming in Cpp
55mMonoids, Monoids, Monoids
01h 03mHigher order functions for ordinary C++ developers
01h 10mSafe and Readable Code - Monadic Operations in C++23
