functional


1. Vector Transformation

#include <vector>

int main() {
  std::vector<int> nums = {1, 2, 3, 4, 5};
  std::transform(nums.begin(), nums.end(), nums.begin(), [](int n) { return n * 2; });
  for (const auto& n : nums) {
    std::cout << n << " "; // Output: 2 4 6 8 10
  }
}

2. Filtering a Collection

#include <vector>
#include <algorithm>

int main() {
  std::vector<int> nums = {1, 2, 3, 4, 5};
  std::vector<int> evens;
  std::copy_if(nums.begin(), nums.end(), std::back_inserter(evens), [](int n) { return n % 2 == 0; });
  for (const auto& n : evens) {
    std::cout << n << " "; // Output: 2 4
  }
}

3. Summing a Collection

4. Finding the Maximum Element

5. Finding the First Odd Element

6. Sorting a Collection

7. Reversing a Collection

8. Generating a Sequence

9. Generating a Fibonacci Sequence

10. Finding the GCD (Greatest Common Divisor)

11. Finding the LCM (Least Common Multiple)

12. Creating a Lambda Function

13. Using Lambda Functions with Algorithms

14. Creating a Functor

15. Partially Applying Functions

16. Creating a Curried Function

17. Using Function Pointers

18. Using Function Objects

19. Using Boost.Lambda

20. Using Expression Templates

21. Using C++20 Concepts

22. Using C++20 Range-based For Loops

23. Using C++20 Structured Bindings

24. Using C++20 Constexpr Functions

25. Using C++20 Lambda Captures

26. Using C++20 Default Function Templates

27. Using C++20 Template Alias

28. Using C++20 Concepts with Templates

29. Using C++20 Fold Expressions

30. Using C++20 Coroutines

31. Using C++20 Modules

32. Using C++20 Concepts with Modules

33. Using C++20 Constexpr Modules

**34. Using C++2