|
6 | 6 | #' |
7 | 7 | #' * A named function, e.g. `mean`. |
8 | 8 | #' * An anonymous function, e.g. `\(x) x + 1` or `function(x) x + 1`. |
9 | | -#' * A formula, e.g. `~ .x + 1`. You must use `.x` to refer to the first |
10 | | -#' argument. No longer recommended. |
| 9 | +#' * A formula, e.g. `~ .x + 1`. Use `.x` to refer to the first argument. No |
| 10 | +#' longer recommended. |
11 | 11 | #' * A string, integer, or list, e.g. `"idx"`, `1`, or `list("idx", 1)` which |
12 | 12 | #' are shorthand for `\(x) pluck(x, "idx")`, `\(x) pluck(x, 1)`, and |
13 | 13 | #' `\(x) pluck(x, "idx", 1)` respectively. Optionally supply `.default` to |
|
33 | 33 | #' 3:10 |> detect_index(is_even, .dir = "backward") |
34 | 34 | #' |
35 | 35 | #' |
36 | | -#' # Since `.f` is passed to as_mapper(), you can supply a |
37 | | -#' # lambda-formula or a pluck object: |
| 36 | +#' # Since `.f` is passed to as_mapper(), you can supply a pluck object: |
38 | 37 | #' x <- list( |
39 | 38 | #' list(1, foo = FALSE), |
40 | 39 | #' list(2, foo = TRUE), |
|
50 | 49 | #' |
51 | 50 | #' # If you need to find all positions, use map_lgl(): |
52 | 51 | #' which(map_lgl(x, "foo")) |
53 | | -detect <- function(.x, .f, ..., .dir = c("forward", "backward"), .default = NULL) { |
| 52 | +detect <- function( |
| 53 | + .x, |
| 54 | + .f, |
| 55 | + ..., |
| 56 | + .dir = c("forward", "backward"), |
| 57 | + .default = NULL |
| 58 | +) { |
54 | 59 | .f <- as_predicate(.f, ..., .mapper = TRUE) |
55 | 60 | .dir <- arg_match0(.dir, c("forward", "backward")) |
56 | 61 |
|
|
0 commit comments