Skip to content

Commit

Permalink
Updated reduce documentation, eliminated accumulate2() and document .…
Browse files Browse the repository at this point in the history
….. itself
  • Loading branch information
ccani007 committed Aug 15, 2024
1 parent d022c4e commit 8c9fb23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
18 changes: 16 additions & 2 deletions R/reduce.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
#' function that takes two values and returns a single value: reducing
#' `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) f(x, 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
10 changes: 4 additions & 6 deletions man/reduce.Rd

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

10 changes: 4 additions & 6 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 8c9fb23

Please sign in to comment.