4 ms·
In an alternate universe where functional programming was invented by programmers rather than mathematicians, map would probably be called something like conver
by twic 12y ago
In an alternate universe where functional programming was invented by programmers rather than mathematicians, map would probably be called something like convertWith and a functor would probably be called something like a convertible.
If you think of a function as being a way of converting from one kind of thing to another, then a functor is an object which has a number of things which you can convert to some other kind (a number which may be one or zero), using a method of your choice, and map is the name of the method you use to do that.
- blahber 12y ago/wow More please ! Also guys, please check this new submission. https://news.ycombinator.com/item?id=7895901 https://news.ycombinator.com/item?id=7895901 Alice and Bob play a cryptographic tetris game. Some french phd bloke has written it.
- dang 12y agoWould you please stop putting "/word" at the top of your comments? Gimmicks like that don't work here.
- blahber 12y ago/love It is a pattern, yes. Let me show you a pattern that I have observed in Hacker News and forums since the demise of USENET. USENET had an elegant way of ignoring without hellbanning, which the negative karma has done to me now. Would you please study the history of Stalinism ? Let me summarise it for you. Ideology -- pg. Yeah, Marx is a good guy too. It is made of dictators and the inner ring -- Admins and Karma users like you. These people have special "powers" of punishment. Admins have far greater powers of purging and renaming things. Then the party cadre -- people who submit and actually keep the things in motion. They are usually not aware of the "inner ring", users like you. They want to help the lay people. In fact no one even knows who is in the inner ring. The inner ring is clueless of the Admins. Then there are lay users like me, who lurk around and want to help but are generally punished. If you think I am shitting you consider the rate of new users becoming high karma users in HN over the years. You can use d3 and it will go the top of HN. Your pedantry is just arbitrary. There is nothing really substantial in it. Rather than judging on the basis of content, you are judging me on the "words" I use. Gimmick: An ingenious or novel device, scheme, or stratagem, especially one designed to attract attention or increase appeal. Why thank you, it is novel :) Please understand the democratic roots of the word "forum" and take it seriously.
- skybrian 12y agoIn Java we would call it "Mappable". A Mappable interface would have one method: map(). It hasn't been all that useful until recently due to lack of closures, but perhaps it would make sense in Java 8? "Functor" is a terrible name that only a mathematician could like.
- Dewie 12y agoWhat discipline did the word "map" come from? ;) Is "map" even descriptive? In a programming concept, the first time I heard it I thought it was referring to the data structure of the same name, which is pretty different.
- skybrian 12y agoYes, good point. I suppose replaceEach() would be a more descriptive name, so the interface might be HasReplaceEach. It's not as easy to talk about, though. Still better than "functor". (The function being passed in to map() is an alternate way to represent a very large map, in a mathematical sense.)
- Chattered 12y agoMathematicians prefer obscure technical terms to misleading and restrictive metaphors, because obscure terms force you to refer solely to (and eventually internalise) a precise and abstract definition. I think this is the case for functors, because I've yet to see a metaphor for them which isn't misleading or restrictive. "replaceEach", for instance, would confuse me. I like working with parser combinators, where parsers are functors. If I replaceEach a parser, what have I replaced? The results of the parse? The parser hasn't been run on an input yet. Maybe it never will. If I replaceEach a promise, what am I replacing? The result of the promise? Maybe the promise will be forever blocked, or maybe I'll cancel it. If I replaceEach a continuation, what am I replacing?
- claudius 12y ago> because obscure terms force you to refer solely to (and eventually internalise) a precise and abstract definition. Unless some C++ people decide that “functor” is a wonderful name for a stateful function-like thing which somewhat resembles closures/lambdas but has nothing whatsoever to do with the functors from functional programming.