fsharp / fsharp/fslang-suggestions
Add Map.merge
- Dominant language
- No language data
- Stars
- 373
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
I propose we add a `Map.merge m1 m2` function to merge two maps. Whenever there is a key conflict the value in m1 is superseded by the value in m2.
The existing way of approaching this problem in F# is to write your own.
The naive implementation looks something like:
```
let merge m1 m2 =
Map.fold (fun s k v -> Map.add k v s) m1 m2
```
## Pros and Cons
The advantages of making this adjustment to F# are it is a handy function and [other languages](http://erlang.org/doc/man/maps.html#merge-2) have it. Also it would most likely be more efficient than the implementation above. I'd be happy to do the work should it be accepted.
The disadvantages of making this adjustment to F# are - how key conflicts are dealt with may not be obvious to new users without reading the documentation.
## Extra information
Estimated cost (S):
Related suggestions: (put links to related suggestions here)
## Affadavit (must be submitted)
Please tick this by placing a cross in the box:
* [x] This is not a question (e.g. like one you might ask on [stack overflow](http://stackoverflow.com)) and I have searched stack overflow for discussions of this issue
* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate
* [x] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
* [x] This is not a breaking change to the F# language design
* [x] I would be willing to help implement and/or test this
* [ ] I or my company would be willing to help crowd-fund F# Software Foundation members to work on this
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.