Re:Functional Programming Jargon
by rbobrowicz on Tuesday November 07, 2017 @04:00PM
(#15647578)
Those are all just particular cases of the same concept. A "map", well, maps values in a domain to values in a codomain. A mathematical function is a map. A key/value data structure can be viewed as a partial function on a non contiguous, discrete domain. A hashmap is just an implementation detail of a key/value structure. A map over an array is again just a function mapping an array in one domain to another array in a codomain.
While that's true in a sense, I think it sweeps important details under the rug, which confuses things more than it enlightens. You can iterate over the domain of a map data structure, but not (in general) a map function.
For purposes of education and communication, I think it's unfortunate that we use the same name for these things.
In a functional language I'd expect it to be #3 every time, no?
my only experience with this being confusing is the immutable.js Map construct.
https://facebook.github.io/immutable-js/docs/#/Map
While this doesn't cause an immense amount of confusion, it does throw me every once in a while.
1) any key/value data structure
2) a hashmap, specifically
3) a function that runs on each element of an array to make a new array