"Having a language that lets you declare constructs that look very similar to their mathematical definition is a huge win for readability."
I'd agree, except every mathematical definition I've seen used infix notation. Minus a function for summing a series, the C version at least keeps the symbols in the same order. Anyone with even a passing familiarity of C can read this and recognize it as the same thing.
double entropy(int x) {
double e = 0.0;
for (int i = 0; i < x; i++) e += p(i) * log(p(i));
return -e;
}
I'd agree, except every mathematical definition I've seen used infix notation. Minus a function for summing a series, the C version at least keeps the symbols in the same order. Anyone with even a passing familiarity of C can read this and recognize it as the same thing.