% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bandwidth_grid.R, R/parallel.R
\name{parallel_map}
\alias{parallel_map}
\title{Minimal parallel_map implementation}
\usage{
parallel_map(x, fn, workers = 1, seed = NULL, ..., packages = NULL)

parallel_map(x, fn, workers = 1, seed = NULL, ..., packages = NULL)
}
\arguments{
\item{x}{A list (or vector) of inputs to iterate over.}

\item{fn}{A function to apply to each element of \code{x}. The function
receives the element as its first argument; additional arguments are
passed via \code{...}.}

\item{workers}{Integer scalar. Number of parallel workers. \code{1}
(default) uses serial \code{lapply} and never touches \code{future}.}

\item{seed}{Integer scalar or \code{NULL}. Random seed for reproducibility.
In serial mode the R RNG is seeded with \code{set.seed(seed)}. In
parallel mode the seed is forwarded to \code{future_lapply} via the
\code{future.seed} argument using L'Ecuyer-CMRG streams.}

\item{...}{Additional arguments forwarded to \code{fn}.}

\item{packages}{Character vector of package names that workers need to load,
or \code{NULL} (default). Ignored in serial mode.}
}
\value{
A list of the same length as \code{x}. Elements where \code{fn}
  threw an error are replaced with a character string \code{"ERROR: <msg>"}.
}
\description{
Wraps `lapply` when `workers = 1` and `parallel::mclapply` when
`workers > 1`.  This stub is superseded once `parallel.R` is available.

A thin wrapper that uses plain \code{lapply} when \code{workers = 1} and
switches to \code{future.apply::future_lapply} with a \code{multisession}
plan for \code{workers > 1}. The global \code{future} plan is always
restored to \code{sequential} after the call, preventing side-effects.
}
\details{
Worker-level errors are caught and returned as character strings (prefixed
with \code{"ERROR: "}) rather than aborting the entire call.
}
\examples{
result <- parallel_map(1:3, function(x) x^2, workers = 1)
stopifnot(identical(result, list(1, 4, 9)))

}
\keyword{internal}
