Learn R Programming

cppcontainers (version 1.0.4)

splice: Move elements

Description

Move elements from one list to another list by reference.

Usage

splice(x, y, x_position, y_from, y_to)

Value

Invisibly returns NULL.

Arguments

x

A CppList object to which to add elements.

y

A CppList object, of the same data type as x, from which to extract elements.

x_position

Index at which to insert elements in x.

y_from

Index of the first element to extract from y.

y_to

Index of the last element to extract from y.

See Also

merge, splice_after.

Examples

Run this code
x <- cpp_list(4:9)
x
# 4 5 6 7 8 9

y <- cpp_list(10:12)
y
# 10 11 12

splice(x, y, 3, 2, 3)
x
# 4 5 11 12 6 7 8 9
y
# 10

Run the code above in your browser using DataLab