4 ms·
While that's true you could implement one that way, it's very nice to have the set operations implemented. Intersection, union, subtraction, etc. And having a u
by mcpherrinm 9y ago
While that's true you could implement one that way, it's very nice to have the set operations implemented. Intersection, union, subtraction, etc. And having a uniform set type makes API signatures more consistent.
Plus you may be able to optimize Set<T> to use less space than Map<T, bool>.
- slig 9y ago> While that's true you could implement one that way, it's very nice to have the set operations implemented Unrelated, but does anyone know why the new JavaScript set implementation is so limited? Why didn't they bother doing this right?
- douche 9y agoBecause it is JavaScript, and there's some kind of unspoken rule about not doing things properly and instead releasing broken things.
- floogtheunfound 9y agoI’m shocked this isn’t being aggressively down voted...oh wait... it’s bashing js and not bashing haskell...nvm
- TheAceOfHearts 9y agoI think I remember reading a claim that they pushed for a small API surface in order to make sure it got through. Now that it's part of the language, anyone else can work on getting those extra features in. You can implement most basic functionality easily enough, MDN even has an example [0]. Although I agree that it should really be part of the language. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Implementing_basic_set_operations https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- deckarep 9y agoThis exactly, I hear over and over: just use a hashtable...totally misses the point.