Skip to content

Commit

Permalink
Updated reduce documentation (#1146)
Browse files Browse the repository at this point in the history
Fixes #1103.
  • Loading branch information
ccani007 authored Aug 20, 2024
1 parent 8ab143a commit 7dea85a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
17 changes: 16 additions & 1 deletion R/reduce.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@
#' `f` over `1:3` computes the value `f(f(1, 2), 3)`.
#'
#' @inheritParams map
#' @param .y For `reduce2()` and `accumulate2()`, an additional
#' @param ... Additional arguments passed on to the reduce function.
#'
#' We now generally recommend against using `...` to pass additional
#' (constant) arguments to `.f`. Instead use a shorthand anonymous function:
#'
#' ```R
#' # Instead of
#' x |> reduce(f, 1, 2, collapse = ",")
#' # do:
#' x |> reduce(\(x, y) f(x, y, 1, 2, collapse = ","))
#' ```
#'
#' This makes it easier to understand which arguments belong to which
#' function and will tend to yield better error messages.
#'
#' @param .y For `reduce2()` an additional
#' argument that is passed to `.f`. If `init` is not set, `.y`
#' should be 1 element shorter than `.x`.
#' @param .f For `reduce()`, a 2-argument function. The function will be passed
Expand Down
8 changes: 4 additions & 4 deletions man/reduce.Rd

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

8 changes: 4 additions & 4 deletions man/reduce_right.Rd

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

0 comments on commit 7dea85a

Please sign in to comment.