-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define map for Sets #51703
Comments
Triage says the structural map for We used to do this long ago, but then @vtjnash had an example of iterating over a set of files asking how big they were and accidentally got wonky results not realizing he was getting and unordered thing out. The feeling was that if we do make this not a method error, then we'd just make it hit the generic fallback map(f, A) = collect(Generator(f, A)) There was a lengthy, mostly inconclusive discussion on "what does |
I see a couple different kinds of map functions. One class has a fixed output type: it takes any collection (iterator, set, whatever) and returns Another kind, sometimes called
A special consideration with If this two-way decomposition is adopted, then A third interpretation of map is a tl;dr: |
I should also mention that Triage almost universally agreed that it was probably a bad idea that we have a special method for |
I know that there is an ongoing discussion about what map should do on Dicts and that there is also a similar closed issue which combined Set/Dict, but really, reading through it does not seem to give any argument why map should not be defined for Sets.
I guess the discussion for Set is what the semantics of
map
is:map
follows the general functor semantics (found e.g. in haskell or Scala), which means that map returns the same parent type which the input has.Let's go for functor semantics (2.) - some thoughts
While for Dict semantics 2 are not really clear in julia, because a dict may be understood as a vector of pairs or some fancy indexed values, for
Set
the semantics 2 is indeed crystal clear.Also within Julia's standard library the SparseVector notably follow semantics 2:
I would also like to argue that, in general, for julia having multiple dispatch it makes far more sense to follow the functor semantics (2.).
map
function in order to stay within their own types.Conclusion
Although the discussion for Dict is not resolved, it makes sense to define map for
Set
in julia.The text was updated successfully, but these errors were encountered: