The Most Average Function There Is
summary
Builds a genuinely single-pass generic mean that picks sum and division types per element kind (signed vs unsigned, integral vs fractional), detects sequences with or without length, and optionally uses Kahan-style compensated sums for floating-point stability. Demonstrates a D implementation using static if introspection to generate optimal code per type, cites a working implementation that fits in 26 lines with ~10 core lines, and notes community reactions (Rust reddit score -18) and broken stdlib examples.
AI-written summary · about
chapters (11)
- 0:00Intro
- 1:00Good Language for Getting Work Done?
- 4:37Second-Order Issues
- 8:48Issue with Ideological Languages
- 15:07Doing What You Want To Do
- 17:51Simple Things to Desire
- 21:22Example: The Average Function
- 24:18A Modest Start
- 38:14Integrals vs. Floating Point
- 48:00Second-Order Insights
- 51:48Code Lines Matter
related talks
01h 09mOverengineering max(a, b) Mixed Comparison Functions, Common References & Rust Lifetime Annotations
01h 03mConstructing Generic Algorithms: Principles and Practice
21mSafe Numerics Library
01h 05mA C++ Approach to Physical Units
55mI Wish I Could Use C++ 1x/y/z
50mRecent Advances in Floating-point (Static) Analyses
42mfixed_point
55m“Using Types Effectively"
