Is there const in C?

There are no syntactic differences between C and C++ with regard to const keyword, besides a rather obscure one: in C (since C99) you can declare function parameters as void foo(int a[const]); which is equivalent to void foo(int *const a); declaration. C++ does not support such syntax. Semantic differences exist as well. As @Ben Voigt … Read more

Make Javascript do List Comprehension

generic case using Array.map, requires javascript 1.6 (that means, works on every browser but IE < 9) or with an object augmenting framework like MooTools works on every browser: var list_of_names = document.getElementsByTagName(‘input’).map( function(element) { return element.getAttribute(‘name’); } ); If dealing with an iterable that doesn’t provide map (such as generators), spread syntax can be … Read more

Is there a Python equivalent to Ruby’s string interpolation?

Python 3.6 will add literal string interpolation similar to Ruby’s string interpolation. Starting with that version of Python (which is scheduled to be released by the end of 2016), you will be able to include expressions in “f-strings”, e.g. name = “Spongebob Squarepants” print(f”Who lives in a Pineapple under the sea? {name}.”) Prior to 3.6, … Read more