Skip to content

Commit

Permalink
Add remove_both function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MHenderson committed Jun 12, 2024
1 parent 31740d6 commit b388ed1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions R/remove-both.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' Remove both elements of a pair from a list
#'
#' @param X A list
#' @param p A pair
#'
#' @return The list X with both elements of p removed (if they exist).
remove_both <- function(X, p) {
m1 <- match(p[1], X)
if(!is.na(m1)) {
X <- X[-m1]
}
m2 <- match(p[2], X)
if(!is.na(m2)) {
X <- X[-m2]
}
return(X)
}
19 changes: 19 additions & 0 deletions man/remove_both.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b388ed1

Please sign in to comment.