% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/util.R
\name{fold_left}
\alias{fold_left}
\alias{fold_right}
\title{Fold left over a sequence}
\usage{
fold_left(init)

fold_right(init)
}
\arguments{
\item{init}{initial value. If not specified \code{NULL}}

\item{x}{the sequence to iterate over}

\item{FUN}{a function with first argument named \code{elem} and second argument
named \code{accum}}
}
\value{
The final value of \code{accum}.
}
\description{
Fold left over a sequence

Fold right over a sequence
}
\examples{
  \dontrun{
    # This produces ...
    fold_left(0)(1:10, \(elem, accum) accum + elem)
    # ... the same as
    sum(1:10)
  }

}
\keyword{internal}
