basedOpinionated utility library |
git clone git://git.dimitrijedobrota.com/based.git |
Log | Files | Refs | README | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | |
functional.cpp (1148B)
1 #include <iostream> 2 3 #include "based/functional.hpp" 4 5 int main() 6 { 7 static const auto func = [](int x) { return x != 32 ? 2 * x : 1; }; 8 static const auto pred = [](int /* x */) { return true; }; 9 10 std::cout << based::distance(1, 16, func) << '\n'; 11 std::cout << based::power_unary(1, 2, func) << '\n'; 12 13 std::cout << '\n'; 14 std::cout << based::collision_point(1, func, pred) << '\n'; 15 std::cout << based::terminating(1, func, pred) << '\n'; 16 std::cout << based::circular(1, func, pred) << '\n'; 17 std::cout << based::connection_point(1, func, pred) << '\n'; 18 19 std::cout << '\n'; 20 std::cout << based::collision_point_nonterminating_orbit(1, func) << '\n'; 21 std::cout << based::circular_nonterminating_orbit(1, func) << '\n'; 22 std::cout << based::connection_point_nonterminating_orbit(1, func) << '\n'; 23 24 std::cout << '\n'; 25 std::cout << based::power(3, 0, std::multiplies<int> {}, 1) << '\n'; 26 for (std::size_t i = 1; i < 8; i++) { 27 std::cout << based::power(3, i, std::multiplies<int> {}) << '\n'; 28 } 29 30 std::cout << '\n'; 31 for (std::size_t i = 0; i < 8; i++) { 32 std::cout << based::fibonacci(i) << '\n'; 33 } 34 35 return 0; 36 }