Nothing wrong with functional programing, in fact it is pretty great, But I wish people would name their functions.
Nothing wrong with functional programing, in fact it is pretty great, But I wish people would name their functions.
zipWith (\i m -> fmap (i,) m) [0..]
Sure, I could rewrite it as ‘zipWith prependToEachElement [0..]’, but if you know Haskell that’s not all that much shorter or clearer, especially for a function which might only be used once in the whole program.But usually, if you're working with a list, it's a list of something specific, and the names should reflect that. If we're doing graphics and those (x,y) points are interpreted as points on a graph, then it's really:
moveUpOne = (x,y) => (x,y + 1)
map(moveUpOne, points)
Or maybe it's moveDownOne? Depends on your coordinate system.Similarly, you're probably prepending to a list for some application-specific reason. The code should use application-specific jargon.
moveUpOne = fmap (+1)
...which uses a map over a functor, in this case a tuple. But once you're familiar with functors, there's not that much benefit in naming something like that, much as you wouldn't typically define `add1 = (+1)`.I also love good names! I hated not being able to have names in formulas and the name part of Named Functions is alone a big quality of live improvement for me.
As to lambdas, perhaps calling them anonymous functions is giving the wrong impression here. What lambdas really are is a simple, native way to create a context with local names. They can be a great boon to clarity through naming!
Spreadsheets have been historically so limited that programmers have resorted to hacky ways to have names/comments. The N function for numerical values is used sometimes for this since N of a string defaults to 0: so N("Name/comment") = 0 and can be added to a formula without changing it.
As to the cultural practice of ultra-short, likely meaningless variable names, like single letters. I do agree it's a "mathy" thing and can quickly descend into maddening opaqueness. The trick though is that sometimes it's very useful to have as compact a symbolic representation as you can manage (such a process of abbreviation gave us algebra!). Naming things is hard, perhaps one of the truly hard things in thinking/programming as the saying goes :)
Wrt maths, you did maths without greek letters and with plain english, you'd have pretty ugly formulas. Greek letters, while obtrusive to newcomers, can be a lifesaver for conciseness in expression.
the fact that most people abuse greek letters for this purpose says more about most people than about the utility of greek letters in formulae.
(but otherwise, yes, I agree with the more general point)