Reputation
11,092
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
1 25 55
Newest
 Fanatic
Impact
~347k people reached

May
12
revised Why dynamically typed languages do not let the developer specify the type?
added 47 characters in body
May
12
comment Why dynamically typed languages do not let the developer specify the type?
@MasonWheeler: A fair point. There are of course ways to do metaprogramming statically, some of them fairly widespread (C++ templates, for instance). I've updated the answer.
May
12
revised Why dynamically typed languages do not let the developer specify the type?
added 47 characters in body
May
6
comment Reuse already fetched data for request
I've updated my answer. The approach really depends on your needs. In a commercial setting, every 100 ms of delay cost you a certain percent of visitors closing the tab. In an internal system, you might have other priorities before you start to optimize for speed, and your network is likely a fast LAN.
May
6
revised Reuse already fetched data for request
added 897 characters in body
May
5
answered Reuse already fetched data for request
May
3
comment Best way to structure many-to-one allocation of users to projects in NoSQL
Just in case: I suppose this is not a centerpiece of your DB design, and there are other, bigger compelling reasons to use NoSQL as opposed to an RDBMS?
May
2
comment Check distance between all elements in a list of numbers in O(n*lg(n))
@StefanPochmann: While I understand that everything hints to a sort-oriented solution, I'd prefer a stricter problem statement. For instance, the 'divide and conquer' hint is not entirely applicable to sorting solution: quicksort does classic divide and conquer, merge sort works a bit differently (and BTW merge sort is always O(N log N), quicksort isn't).
May
2
comment Check distance between all elements in a list of numbers in O(n*lg(n))
«all numbers in a list X have distance greater or equal to k from each other» is a bit unclear to me. What is "each other" — just neighbors or an arbitrary other number in the list? For the former, an O(N) solution is obvious, for the latter, an O(N log N) solution with sorting is also obvious.
May
1
answered Close to knapsack problem?
Apr
30
comment Using System.err.println() for debugging in Java
One problem with printing directly to stderr is that output from parallel threads gets intermingled. Logging fixes that.
Apr
30
comment Using System.err.println() for debugging in Java
Print-based debugging is usually OK as a temporary measure for catching a problem quickly. It should be removed from production code. Use proper logging to track the steps your program is taking.
Apr
28
comment fast, say O(log2(N)), sliding median algorithm
Well, yes, on the second thought, neither of them are applicable here. Sorry.
Apr
28
comment fast, say O(log2(N)), sliding median algorithm
I can imagine using a Bloom filter or a HyperLogLog counter to approximate the 2^32 histogram, and maybe keeping more levels of the histogram.
Apr
28
comment Should we always DRY? Any edge case examples of when not to?
I can think of one example where some amount of repetition may be fine: tests.
Apr
24
comment Does anybody recognize this scheduling problem? Is there an algorithm for it?
/* A nitpick: quanta is plural for quantum; "a quanta" sounds weird. */
Apr
23
comment Why python function programming functions are not collection methods?
@Doval: The thing is, most languages (both their authors and communities) are opinionated. Ruby and Python are pretty similar in many regards, but they hold very different opinions about the proper style. For instance, Go is highly opinionated, but so are Java, Scala, Haskell, etc. Also note that opinions are in many cases opinions, not hard limits; you can write highly procedural Java, highly functional Python, highly imperative Haskell, etc. It usually goes a bit against the grain of the language, but you can do it if you must, that is, when it has very definite upsides.
Apr
23
comment Why python function programming functions are not collection methods?
@Doval: read the example again: the list comprehensions take about as much room as function-calling ones. For summation (actually, for everything that uses + as the operation) you can just use sum (e.g. sum([(1, 2), (3, 4)], ()) would concatenate tuples). Yo can import operator if reduce(int.__add__,...) looks clumsy to you. Also, reduce isn't going anywhere.
Apr
23
revised Why python function programming functions are not collection methods?
deleted 3 characters in body
Apr
23
answered Why python function programming functions are not collection methods?