Get the latest tech news

Stepanov's biggest blunder? The curious case of adjacent difference


How STL algorithms parallel the fundamental theorem of calculus.

The few times I needed to compute pairwise differences, the semantics of std::adjacent_difference stood in the way, and I ended up writing a custom loop. I disagree with Stepanov’s design choice, but I’m glad it made me question his intentions and find these hidden connections. This design preserves symmetry with partial sums but avoids the type mismatch between the input and output sequences, achieving both elegance and pragmatism.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of curious case

curious case

Photo of Stepanov

Stepanov

Photo of biggest blunder

biggest blunder

Related news:

News photo

The curious case of the Unix workstation layout

News photo

Only on Nantucket: The Curious Case of the "Stolen" Mercedes

News photo

The curious case of shell commands, or how "this bug is required by POSIX" (2021)