enumerateit {FastUtils}R Documentation

Enumerate Elements with Indices

Description

This function pairs elements of vectors or lists with their indices. The output is meant to be used in a for loop, and each element extracted with the ind(), val(), or val1() functions. A slightly lighter weight alternative to itertools::enumerate()

Usage

enumerateit(..., zero_indexed = FALSE)

Arguments

...

Vectors or lists to be enumerated.

zero_indexed

A logical indicating whether indexing should start from zero. Default is FALSE.

Value

A list of lists, where each inner list contains an index and the corresponding elements from the input vectors or lists.

See Also

ind(), val(), val1()

Examples

# Enumerate a vector
enumerateit(c("a", "b", "c"))
# Enumerate a vector starting from zero
enumerateit(c("a", "b", "c"), zero_indexed = TRUE)
# Enumerate two vectors
enumerateit(c(1, 2), c("x", "y"))

[Package FastUtils version 0.1.1 Index]