This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename T, template<typename...> class C, typename... Args> | |
| C<T, Args...> in (C<T, Args...>& input, auto func) | |
| { | |
| C<T, Args...> items; | |
| for (auto inp=input.begin(); inp!=input.end(); inp++) (void)items.insert(items.end(),func(*inp)); | |
| return items; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include <deque> | |
| #include <map> | |
| #include <set> | |
| #include <list> | |
| #include <string> | |
| using namespace std; | |
| int main() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| template <typename T, size_t S> | |
| class into : public std::array<T,S> | |
| { | |
| public: | |
| into (std::array<T,S>& input, auto func) | |
| { | |
| for (size_t i=0; i<this->size(); i++) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set nums = {1,2,3,4}; | |
| auto result = in(nums, [](auto x) { return x*x; }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set nums = {1,2,3,4}; | |
| auto result = in(nums, each(x, x*x)); // insert all elements multiplied by themselves | |
| auto result = in(nums, each(x, (x>2)?x*x:x)); // insert all elements but only multiply those that fulfill the condition | |
| auto result = in(nums, only(x, x<2, x*x)); // insert only the elements that fulfill the condition | |
| auto result = in(nums, only(x, x<4 && cout<<x, x*x)); // insert and print only the elements that fulfill the condition (prints: 123) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nums = [1,2,3,4] | |
| result = [x*x for x in nums] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <deque> | |
| template <class T> | |
| class table | |
| { | |
| public: | |
| table<T> select (const auto& where) | |
| { | |
| table results; | |
| for(auto t : rows) if (where(t)) results.insert(t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int e = 10; | |
| int *p = &e; | |
| const int *q = &e; | |
| void reset_none (const int * const & ptr) { static int a = 11; /* (*ptr=a); (ptr=&a); */ } | |
| void reset_value_only (int * const & ptr) { static int a = 12; (*ptr=a); /* (ptr=&a) */ } | |
| void reset_pointer_only (const int * & ptr) { static int a = 13; /* (*ptr=a); */ ptr=&a; } | |
| int main() | |
| { | |
| reset_none(p); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SncSensor| Arduino Board | |
| // UCC = 5v on the POWER row | |
| // TRIGGER = -9 pin | |
| // ECHO = -10 pin | |
| // GND = any GND | |
| int trigPin = 9; | |
| int echoPin = 10; | |
| int led1 = 13; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <list> | |
| #include <cstdlib> | |
| #include <cstring> | |
| #include <cassert> | |
| namespace owl { | |
| class memory | |
| { | |
| public: |
NewerOlder