Skip to content

Latest commit

 

History

History
 
 

21

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Exercise 10.21

Write a lambda that captures a local int variable and decrements that variable until it reaches 0. Once the variable is 0 additional calls should no longer decrement the variable. The lambda should return a bool that indicates whether the captured variable is 0.

solution

[&i]() { return i > 0 ? !--i : !i; };