Skip to content
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 mergewith[!] #18

Closed
wants to merge 2 commits into from
Closed

Define mergewith[!] #18

wants to merge 2 commits into from

Conversation

tkf
Copy link

@tkf tkf commented May 13, 2020

This PR adds mergewith! and mergewith (and also merge). It's kind of nice that we can use curried form like mergewith!(+) now. Some random example:

julia> mapfoldl(mergewith!(+), rand(1000) .* maxintfloat()) do x
           dictionary(digits(floor(Int, x))[end] => 1)
       end |> pairs |> collect |> sort!
9-element Array{Pair{Int64,Int64},1}:
 1 => 119
 2 => 126
 3 => 117
 4 => 142
 5 => 121
 6 => 119
 7 => 123
 8 => 114
 9 => 19

@codecov-io
Copy link

codecov-io commented May 13, 2020

Codecov Report

Merging #18 into master will decrease coverage by 3.19%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #18      +/-   ##
==========================================
- Coverage   61.79%   58.59%   -3.20%     
==========================================
  Files          18       18              
  Lines        1039     1135      +96     
==========================================
+ Hits          642      665      +23     
- Misses        397      470      +73     
Impacted Files Coverage Δ
src/Dictionaries.jl 100.00% <ø> (ø)
src/insertion.jl 41.21% <83.33%> (+0.91%) ⬆️
src/indexing.jl 45.83% <0.00%> (-15.28%) ⬇️
src/broadcast.jl 51.78% <0.00%> (-6.22%) ⬇️
src/filter.jl 55.55% <0.00%> (-5.43%) ⬇️
src/tokens.jl 22.95% <0.00%> (-4.51%) ⬇️
src/Dictionary.jl 73.17% <0.00%> (-3.76%) ⬇️
src/map.jl 27.02% <0.00%> (-3.28%) ⬇️
src/AbstractDictionary.jl 72.06% <0.00%> (-2.94%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b22a25...1267422. Read the comment docs.

@andyferris
Copy link
Owner

Thanks @tkf - this is a good idea.

Maybe I'm a bit odd but I been avoiding Compat.jl for foundational packages, just to minimize the number of dependencies etc...

@tkf
Copy link
Author

tkf commented May 31, 2020

I'm OK with removing Compat dependency. Actually, Compat.mergewith[!] would work with Dictionaries.jl even without the explicit support because the definition I added in Compat.jl is pretty generic: https://github.com/JuliaLang/Compat.jl/blob/1bb5dc7b9c98b4b4f834bebcefa813725dee0d43/src/Compat.jl#L360-L366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants