Erlang's great though. Glad to see some irrational exuberance for it.
Erlang's great though. Glad to see some irrational exuberance for it.
f [n] = [n]
f [m, n] = [m, n, 0, 1]
f [m, n, r, 1] = [m, n, mod m n, 2]
f [m, n, r, 2] = if r == 0 then [n] else [m, n, r, 3]
f [m, n, p, 3] = [n, p, p, 1]
It needs to be implemented with variable-length lists instead of fixed-length tuples, in order to satisfy the type system.
Do you think it is because other programming languages don't uses the semi-colon that way? Or that periods are usually used to access class members, but not to finish function declarations?
The two clauses separated by a semicolon are sentences; thus the semicolon is logically and grammatically equivalent to a full stop. (As long as you normalise the capitalisation). The difference is in nuance, flow, and other soft things.
So when do you use a semicolon instead of a full stop? Whenever you want to!
The really difficult punctuation mark in English is the full colon.
I've mostly wrote this joke since many Erlang beginners find the semi-colon/period syntax confusing, but then there you have it on an essential book about programming
One thing is for sure: just trying to read TAOCP will eventually make you better at math.
I agree with your second sentence, and, as a mathematician and a teacher, I think that I agree with the spirit of the first, but I think that it's probably not worded as you mean. Think of the same sentence with, say, 'baseball' in place of 'math': I think that most people would agree with the second sentence, but not the first. By the same token, there's no such thing as "being inherently good" (or, for that matter, inherently bad) "at math"; but I think that it would be silly to pretend that the effort and practice don't make you good (or at least better) at it.
In my experience, it is we programmers who care about syntax the most. Math folks seem to be happy if you can get the gist of something.
Still, you're right, the semicolon/period thing is troubling for Erlang beginners, but that part of the syntax really does come from Prolog.
A more precise title would be "Erlang uses math-like notation (and kudos)"