vctrs
vctrs copied to clipboard
Generic diff?
Like the Unix command line diff
, not base::diff()
.
I added some diff functions to cli, that are internally completely generic, and I think they would work great for vctrs: https://github.com/r-lib/cli/blob/master/R/diff.R https://github.com/r-lib/cli/blob/master/src/diff.c
To implement diff for a new type, you only need to supply a function that compares if two instances of the type are equal or not (_cmp_chr()
in the C code). You'd also need some format/print methods if you want to print the result nicely.
Otherwise the C code for calculating the edit operations and the R code for calculating chunks from the edit operations are completely generic.
I can submit a PR that implements the low level stuff if you are interested.