Skip to content

Commit

Permalink
Use arg_match0() instead of arg_match() (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich authored Jul 26, 2023
1 parent 60e3ba2 commit c342361
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/adverb-compose.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#' fn <- compose(!!!fns)
#' fn("input")
compose <- function(..., .dir = c("backward", "forward")) {
.dir <- arg_match(.dir, c("backward", "forward"))
.dir <- arg_match0(.dir, c("backward", "forward"))

fns <- map(list2(...), rlang::as_closure, env = caller_env())
if (!length(fns)) {
Expand Down
4 changes: 2 additions & 2 deletions R/detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' which(map_lgl(x, "foo"))
detect <- function(.x, .f, ..., .dir = c("forward", "backward"), .right = NULL, .default = NULL) {
.f <- as_predicate(.f, ..., .mapper = TRUE)
.dir <- arg_match(.dir)
.dir <- arg_match0(.dir, c("forward", "backward"))

for (i in index(.x, .dir, .right, "detect")) {
if (.f(.x[[i]], ...)) {
Expand All @@ -58,7 +58,7 @@ detect <- function(.x, .f, ..., .dir = c("forward", "backward"), .right = NULL,
#' @rdname detect
detect_index <- function(.x, .f, ..., .dir = c("forward", "backward"), .right = NULL) {
.f <- as_predicate(.f, ..., .mapper = TRUE)
.dir <- arg_match(.dir)
.dir <- arg_match0(.dir, c("forward", "backward"))

for (i in index(.x, .dir, .right, "detect_index")) {
if (.f(.x[[i]], ...)) {
Expand Down
4 changes: 2 additions & 2 deletions R/reduce.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ reduce_impl <- function(.x,
.dir,
.acc = FALSE,
.purrr_error_call = caller_env()) {
left <- arg_match(.dir, c("forward", "backward")) == "forward"
left <- arg_match0(.dir, c("forward", "backward")) == "forward"

out <- reduce_init(.x, .init, left = left, error_call = .purrr_error_call)
idx <- reduce_index(.x, .init, left = left)
Expand Down Expand Up @@ -478,7 +478,7 @@ seq_len2 <- function(start, end) {
#' }
#' @export
accumulate <- function(.x, .f, ..., .init, .dir = c("forward", "backward"), .simplify = NA, .ptype = NULL) {
.dir <- arg_match(.dir, c("forward", "backward"))
.dir <- arg_match0(.dir, c("forward", "backward"))
.f <- as_mapper(.f, ...)

res <- reduce_impl(.x, .f, ..., .init = .init, .dir = .dir, .acc = TRUE)
Expand Down

0 comments on commit c342361

Please sign in to comment.