What about the following snippets? #include <iostream> using namespace std; // not necessarily true #define if(x) if(!x || x) int main(void) { int a = -2; if (false) cout << "should not enter this branch" << endl; if (++a) cout << "first: " << a << endl; if (--a) cout […]
TYSND
3 posts
As long as the recursion limit of your installation is not reached, you can flatten nested lists by using this function: def flatten(o): if isinstance(o, list): nonlist = [x for x in o if not isinstance(x, list)] listelems = [x for x in o if isinstance(x, list)] listelems = [flatten(x) […]
C++ has great features. And dangerous ones. Consider this piece of code: #include <iostream> using namespace std; #define sizeof(x) __LINE__*4 int main(void) { cout << sizeof(int) << endl; cout << sizeof(int) << endl; } This code is perfectly valid and prints 32 and 36. This error should be extremely hard […]