% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/parallel.R
\name{with_reproducible_seed}
\alias{with_reproducible_seed}
\title{Execute an expression with a reproducible seed}
\usage{
with_reproducible_seed(seed, expr)
}
\arguments{
\item{seed}{Integer scalar. Seed value passed to \code{set.seed}.}

\item{expr}{An R expression to evaluate.}
}
\value{
The value of \code{expr}.
}
\description{
Sets \code{set.seed(seed)} before evaluating \code{expr}, then restores the
prior RNG state so the caller's random stream is unaffected.
}
\examples{
r1 <- with_reproducible_seed(42, runif(3))
r2 <- with_reproducible_seed(42, runif(3))
stopifnot(identical(r1, r2))

}
