(*)~changed up makefile recipes, cleaned up README
This commit is contained in:
27
list.cpp
27
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;
|
||||
|
||||
Reference in New Issue
Block a user