% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/30-api-flexseq-ends.R
\name{insert_at}
\alias{insert_at}
\title{Insert Elements at a Position}
\usage{
insert_at(x, index, values)
}
\arguments{
\item{x}{A \code{flexseq}.}

\item{index}{One-based insertion position in \verb{[1, length(x) + 1]}.}

\item{values}{Values to insert.}
}
\value{
Updated sequence with inserted values.
}
\description{
Inserts \code{values} before the current element at \code{index}.
}
\details{
\code{values} is interpreted as a collection of elements to splice in.

Common cases:
\itemize{
\item Atomic vector (\code{c("x", "y")}): inserts one element per vector entry.
\item List (\code{list("x", "y")}): inserts one element per list entry.
\item \code{flexseq}: inserts all of its elements.
\item Empty input (\code{list()} or \code{flexseq()}): no change.
}

To insert one composite object (for example, a vector or a list) as a single
element, wrap it in \code{list(...)}.

This operation is persistent: \code{x} is not modified.
}
\examples{
x <- flexseq("a", "b", "c", "d")
insert_at(x, 3, c("x", "y"))
insert_at(x, 1, "start")
insert_at(x, length(x) + 1, "end")

# Insert one vector as a single element
insert_at(x, 3, list(c("u", "v")))
}
