rusty/main.cpp

22 lines
894 B
C++
Raw Normal View History

2023-01-14 06:39:16 +00:00
#include <iostream>
#include <memory>
#include "rusty.hpp"
int main() {
rs::vector<rs::vector<int>> v = {{10, 20, 25}, {30, 40, 55}, {60, 73, 80}};
auto res = v.into_iter_ptr<true>().flat_map([](const rs::vector<int>* v)->auto{return v->into_iter<true>();})
// .partition<rs::list<int>>([](int x) -> auto { return x % 2 == 0; });
// .skip_while([](int v)->bool { return v < 30; })
.inspect([](int x) { std::cout << "check " << x << std::endl;})
// .map([](int x)->float{ return x * 3.14159;})
// .take_while([](float v)->bool { return v < 100; })
// .enumerate()
// .collect<rs::vector<int>>();
.sum();
std::cout << res << std::endl;;
rs::map<int, float> mp = {{1, 4.0}, {2, 6.0}, {3, 6.6}};
std::cout << mp.into_iter().map([](int a, float b)->float{ return a + b * b; }).sum() << std::endl;
return 0;
}