split_at: Split at a Position or Name

View source: R/20-api-generics.R

split_atR Documentation

Split at a Position or Name

Description

Splits by a single one-based position or a single element name.

Usage

split_at(x, at, pull_index = FALSE)

Arguments

x

A flexseq.

at

A single positive integer position or a single character name.

pull_index

Controls output shape:

  • FALSE (default): returns list(left, value, right).

  • TRUE: returns list(left, right).

Details

split_at(x, at, pull_index = FALSE) is a convenience wrapper around split_around_by_predicate() using positional scanning.

split_at(x, at, pull_index = TRUE) is the two-way variant using split_by_predicate().

Value

A split result with shape controlled by pull_index.

Examples

x <- flexseq("a", "b", "c", "d")
split_at(x, 3)
split_at(x, 3, pull_index = TRUE)

n <- flexseq(a = 1, b = 2, c = 3)
split_at(n, "b")

Immutables documentation built on April 29, 2026, 1:06 a.m.