aboutsummaryrefslogtreecommitdiff
path: root/list.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-06-25 07:38:39 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-06-25 07:38:39 +0100
commitdc090ace5f0f1f07dbd6be6b7aa7b7e35a7a7f9a (patch)
tree4c9b06028e51da087bb41c2aaee0b8ad0c1bea5a /list.cpp
parent6d504da381d07115e7bc47b07276ba9105c541c0 (diff)
downloadalgorithms-dc090ace5f0f1f07dbd6be6b7aa7b7e35a7a7f9a.tar.gz
algorithms-dc090ace5f0f1f07dbd6be6b7aa7b7e35a7a7f9a.tar.bz2
algorithms-dc090ace5f0f1f07dbd6be6b7aa7b7e35a7a7f9a.zip
(*)~changed up makefile recipes, cleaned up README
Diffstat (limited to 'list.cpp')
-rw-r--r--list.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/list.cpp b/list.cpp
index 8697d06..aa04294 100644
--- a/list.cpp
+++ b/list.cpp
@@ -107,26 +107,33 @@ int main(void)
std::cout << lst << std::endl;
puts("Reverse list again...");
printf("Map list with f(x) = 2x: ");
- map<int, int>(lst = reverse(lst), [](int x) {
- return x * 2;
- });
+ map<int, int>(lst = reverse(lst),
+ [](int x)
+ {
+ return x * 2;
+ });
std::cout << lst << std::endl;
puts("Reverse map...");
- map<int, int>(lst, [](int x) {
- return x / 2;
- });
+ map<int, int>(lst,
+ [](int x)
+ {
+ return x / 2;
+ });
printf("Sum all numbers in list: ");
std::cout << reduce<int>(
lst,
- [](int a, int b) {
+ [](int a, int b)
+ {
return a + b;
},
0)
<< std::endl;
printf("Print all even numbers 1..10: ");
- auto evens = filter<int>(lst, [](int a) {
- return a % 2 == 0;
- });
+ auto evens = filter<int>(lst,
+ [](int a)
+ {
+ return a % 2 == 0;
+ });
std::cout << evens << std::endl;
delete lst;
delete evens;