Exercises in this lecture  previous -- Keyboard shortcut: 'p'        Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 3.1
Get some experience with lambda expressions in C++


This is an open exercise about lambda expressions in C++. Overall, the purpose is to get some practical experience with lambda expressions in C++, based on our knowledge of lambda expressions in functional programming languages.

One way to go: Write some small C++ programs that illustrate the various forms of capture as described in section 11.4.3 (page 293) in The C++ Prog. Lang. (4. edition).

Another way to go: Make some experiments with mapping, filtering, and accumulation supported by higher-order C++ functions and C++ lambda expressions. Feel free to use vectors, or another kind of container for your experiments. You may find inspiration in the PP lecture about higher-order functions.

A third way to go: Functions cannot be nested in C++. Do some research on nesting of lambda expression into each other.

Feel free to choose your own experiments!


There is no solution to this exercise