Python map object is not subscriptable

In Python 3, map returns an iterable object of type map, and not a subscriptible list, which would allow you to write map[i]. To force a list result, write However, in many cases, you can write out your code way nicer by not using indices. For example, with list comprehensions:

C Vector/ArrayList/LinkedList

For resizable arrays you can use malloc() and realloc(). These allow you to reserve (with malloc()) and resize (with realloc()) a certain amount of space on the heap. They’re used this way: Just replace ‘int’ with your struct type. 😉

Categories c Tags

Breaking out of nested loops

It has at least been suggested, but also rejected. I don’t think there is another way, short of repeating the test or re-organizing the code. It is sometimes a bit annoying. In the rejection message, Mr van Rossum mentions using return, which is really sensible and something I need to remember personally. 🙂

Is it possible to have a multi-line comments in R?

You can, if you want, use standalone strings for multi-line comments — I’ve always thought that prettier than if (FALSE) { } blocks. The string will get evaluated and then discarded, so as long as it’s not the last line in a function nothing will happen. The main limitation is that when you’re commenting stuff out, you’ve … Read more

Setting std=c99 flag in GCC

Instead of calling /usr/bin/gcc, use /usr/bin/c99. This is the Single-Unix-approved way of invoking a C99 compiler. On an Ubuntu system, this points to a script which invokes gcc after having added the -std=c99 flag, which is precisely what you want.