There might not be a better term for the operands of a suitably uncommon and abstract structure X than “things X operates on”, so the single-letter names are as good as any.
No, they aren’t! You can’t search to jump between the usages and definitions of a single-letter name, but you can jump between the usages and definitions of a full-word name, even if that name is blarghle.
Haskell calls the sequences x:xs for “current x” and “the rest of the exes”, which is pretty much all you can say about them from the context of the higher-order function.
Haskell can get away with this because it has strict, well-defined scoping rules which ensure that the names x and xs never appear too far from their definitions, and there is an algorithm which text editors can implement to find those definitions. Math books do not have either of those benefits.
Even worse than trying to search for single-letter variables that are defined somewhere in a mathematical text is trying to find the definitions of operators, if all you know is the squiggle used to denote that operator. For example, integrals are denoted by a slide-looking squiggle, so if you see one and don’t know it’s called an “integral”, you can’t look up what it means. If you do find a definition, the Wikipedia page you’ll get describes integrals as “the signed area of region bound by (the function parameter’s) graph”, with a full-page of explanation and links to 5 or 6 pages of supplementary explanation. Good luck translating that into code!
What you won’t find is the 5-line program that shows you how to actually calculate an integral (for that, see this page from SICP). Mathematicians descend into maddening vaguery when trying to describe concepts that could easily be described by a very short computer program, because math notation (and therefore mathematical study itself) lacks an equivalent of the for loop. So instead, mathematicians think they’re describing something so fundamental that it’s ineffable—Integrals, man! Integrals! Either you grok it, or you don’t.
Haskell can get away with this because it has strict, well-defined scoping rules which ensure that the names x and xs never appear too far from their definitions, and there is an algorithm which text editors can implement to find those definitions. Math books do not have either of those benefits.
Actually, they do, since x and xs are bound variables. Now, variable binding in mathematics is more complicated than it needs to be, but “forall x ”, “exists x ”, “f(x) =”, “d / d x”, “int … d x”, “sum_( i = 0 .. k)” … are variable binding operators, which are quite comparable to the Haskell syntax binding x and xs in the definition of foldr.
Haskell also has support for free variables bound by a closure, where the scoping rules are not so strict and well-defined. But I would expect Haskell programmers to use more readable names for these.
No, they aren’t! You can’t search to jump between the usages and definitions of a single-letter name, but you can jump between the usages and definitions of a full-word name, even if that name is blarghle.
Haskell can get away with this because it has strict, well-defined scoping rules which ensure that the names x and xs never appear too far from their definitions, and there is an algorithm which text editors can implement to find those definitions. Math books do not have either of those benefits.
Even worse than trying to search for single-letter variables that are defined somewhere in a mathematical text is trying to find the definitions of operators, if all you know is the squiggle used to denote that operator. For example, integrals are denoted by a slide-looking squiggle, so if you see one and don’t know it’s called an “integral”, you can’t look up what it means. If you do find a definition, the Wikipedia page you’ll get describes integrals as “the signed area of region bound by (the function parameter’s) graph”, with a full-page of explanation and links to 5 or 6 pages of supplementary explanation. Good luck translating that into code!
What you won’t find is the 5-line program that shows you how to actually calculate an integral (for that, see this page from SICP). Mathematicians descend into maddening vaguery when trying to describe concepts that could easily be described by a very short computer program, because math notation (and therefore mathematical study itself) lacks an equivalent of the for loop. So instead, mathematicians think they’re describing something so fundamental that it’s ineffable—Integrals, man! Integrals! Either you grok it, or you don’t.
Actually, they do, since x and xs are bound variables. Now, variable binding in mathematics is more complicated than it needs to be, but “forall x ”, “exists x ”, “f(x) =”, “d / d x”, “int … d x”, “sum_( i = 0 .. k)” … are variable binding operators, which are quite comparable to the Haskell syntax binding x and xs in the definition of foldr.
Haskell also has support for free variables bound by a closure, where the scoping rules are not so strict and well-defined. But I would expect Haskell programmers to use more readable names for these.
Some reasons that mathematicians use compact variable names are discussed here.