question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is assoc function and there is assocPath, they solve one of the goals properly, but shouldn’t there be a path analogue for merge as well?

A common case, you must travel 4 levels deep into an object and merge objects under same key, it can be done with composition, such as this:

const lens = R.lensPath(['a', 'b']);
R.over(lens, R.merge(R.__, {c2: 22, c3: 33}), {a: {b: {c1: 1, c2: 2}}});
//> {a: {b: {c1:1, c2: 22, c3: 33}}}

But isn’t this a common usage case? So something like R.mergePath([‘a’, ‘b’], {c2: 22, c3: 33}, {a: {b: {c1: 1, c2: 2}}})

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
CrossEyecommented, Sep 1, 2017

Just catching up.

My feeling is that something like mergePath is the sort of function for which we created the Cookbook. If we see a lot of demand, we could consider moving it into the library.

1reaction
CrossEyecommented, Oct 9, 2017

@char0n: I seem to have missed a bunch of messages. Those look fine for the Cookbook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function to concatenate paths? - r - Stack Overflow
The function works only with slashes as path separator, which is fine, since R transparently translates them to backslashes on Windows machine.
Read more >
A path join function - R-Project.org
This function joins strings into a valid path. It is a simple version of python's os.path.join and fixes simple problems such as having/not...
Read more >
merge: Merge Two Data Frames - Rdrr.io
merge is a generic function whose principal method is for data frames: the default method coerces its arguments to data frames and calls...
Read more >
How to use the merge() function for data frames in R
The merge() function in R combines two data frames. The most crucial requirement for connecting two data frames is that the column type...
Read more >
Merge all files in a directory using R into a single dataframe
Merging the Files into a Single Dataframe ... The final step is to iterate through the list of files in the current working...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found