09 Mar 2017
Tags:
C++
This morning, I realized that there is a fourth approach to appending items to a vector that combines elements of the first and third. I’m embarrassed to have missed this one because it is a longstanding, well-understood approach that’s particularly applicable to the kinds of “list comprehension algorithms” I’m considering in this series.
more ...
07 Mar 2017
Tags:
C++
Update: See also the next post, which adds a fourth idiom and mitigates some of the criticisms in the conclusion of this post.
The STL code for squaring the positive values, included the following lines to create the intermediate result t1 containing the positive values of the original list a:
more ...
03 Mar 2017
Tags:
C++
The post presenting the failure case for iterators contrasted this simple Python list comprehension:
more ...
25 Feb 2017
Tags:
C++
My last post, highlighting the differences between C++ lambdas and the lambdas in languages based upon functional programs, went more deeply into the weeds than I had intended. I realized too late that it cried out for examples. The rules for declaring free variables (the member variables of the anonymous class) in C++ lambdas can seem contorted but most uses of them fall into one of a few simple types. In this post, I want to present three simple use cases of C++ lambdas, each demonstrating a different way to use free variables.
more ...