Skip to content

Commit d4b3964

Browse files
RacecarBTFRacecarBTF
RacecarBTF
authored and
RacecarBTF
committed
Adding greedy-merge and greed-distinct-merge
1 parent ef2a371 commit d4b3964

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.1.2
2+
- Adding `greedy-merge` and `greedy-distinct-merge`, and adding documentation for these methods
3+
14
## 0.1.1
25
- Accidentally made `index-merge-with` private
36

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ At this point, merging is divided into 3 types of comparisons:
1313
* `concat-merge`/`concat-merge-with` - Puts all items into one vector
1414
* `distinct-merge`/`distinct-merge-with` - Puts all items into one deduplicated vector
1515
* `index-merge`/`index-merge-with` - Handled with recursive calls using all values at each index and puts the results in a vector
16-
* **Other** - All functions that end with `-with` take a first parameter of a function that will handle these situations. All functions that lack this ending use the value from the last argument passed in
16+
* **Other**
17+
* All functions that end with `-with` take a first parameter of a function that will handle these situations. All functions that lack this ending use the value from the last argument passed in
18+
* There are two other special merge methods that handle these scenarios
19+
* `greedy-merge` - Does a `concat-merge-with` and puts other values into a single vector
20+
* `greedy-distinct-merge` - Does a `distinct-merge-with` and puts other values into a single deduplicated vector
1721

1822
## Merge Requests
1923
In order to make recommendations to this library, either please

project.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
(defproject clojure-deep-merge "0.1.1"
1+
(defproject clojure-deep-merge "0.1.2"
22
:url "https://github.com/JasonStiefel/clojure-deep-merge"
33
:license {:name "Eclipse Public License"
44
:url "http://www.eclipse.org/legal/epl-v10.html"}
5-
:dependencies [[org.clojure/clojure "1.8.0"]]
5+
:dependencies [[org.clojure/clojure "1.10.0"]]
66
:main ^:skip-aot clojure-deep-merge.core
77
:target-path "target/%s"
88
:profiles {:uberjar {:aot :all}})

src/deep/merge.clj

+2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
;;;;;;;;;;;;;;;;;;;;;
4444
(def concat-merge-with (partial deep-coll-merge-with concat-coll-merge))
4545
(def concat-merge (partial concat-merge-with #(last %&)))
46+
(def greedy-merge (partial concat-merge-with #(into [] %&)))
4647
(def distinct-merge-with (partial deep-coll-merge-with distinct-concat-coll-merge))
4748
(def distinct-merge (partial distinct-merge-with #(last %&)))
49+
(def greedy-distinct-merge (partial distinct-merge-with #(into [] (distinct %&))))
4850
(defn index-merge-with
4951
[non-collection-merge-method & vals]
5052
(apply deep-coll-merge-with (partial index-coll-merge non-collection-merge-method) non-collection-merge-method vals))

0 commit comments

Comments
 (0)