Geometric Mean: is there a built-in?
No, but there are a few people who have written one, such as here. Another possibility is to use this: exp(mean(log(x)))
No, but there are a few people who have written one, such as here. Another possibility is to use this: exp(mean(log(x)))
You could add pushd () { command pushd “$@” > /dev/null } popd () { command popd “$@” > /dev/null } to the top of each script. This is probably the minimum amount of work it will take to solve your problem.
Imagine the assembly code that would be generated from: if (__builtin_expect(x, 0)) { foo(); … } else { bar(); … } I guess it should be something like: cmp $x, 0 jne _foo _bar: call bar … jmp after_if _foo: call foo … after_if: You can see that the instructions are arranged in such an … Read more
Actually, Guido vetoed the idea: http://bugs.python.org/issue1093 But, as noted in that issue, you can make one pretty easily: from functools import reduce # Valid in Python 2.6+, required in Python 3 import operator reduce(operator.mul, (3, 4, 5), 1)
Historically, Bourne shells didn’t have true and false as built-in commands. true was instead simply aliased to :, and false to something like let 0. : is slightly better than true for portability to ancient Bourne-derived shells. As a simple example, consider having neither the ! pipeline operator nor the || list operator (as was … Read more