3 ms·
My biggest request would be to add "map" to the list, precisely because it's ambiguous. It could mean: 1) any key/value data structure 2) a hashmap, specifica
by dfabulich 9y ago
My biggest request would be to add "map" to the list, precisely because it's ambiguous. It could mean:
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
- Mikeb85 9y agoIn a functional language I'd expect it to be #3 every time, no?
- castis 9y agomy only experience with this being confusing is the immutable.js Map construct. https://facebook.github.io/immutable-js/docs/#/Map 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.
- rbobrowicz 9y agoThose 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.
- skybrian 9y agoWhile 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.