Skip to contents

i_concat(obj) takes an iterable that returns iterables, and chains together all inner values of iterables into one iterator. Analogous to unlist(recursive=FALSE).

i_chain for iterators is analogous to c() on vectors. i_chain constructs an iteror that returns elements from the first argument until it is exhausted, then elements from the next argument, and so on until all arguments have been exhausted.

Usage

i_concat(obj, ...)

i_chain(...)

Arguments

obj

an iterable.

...

multiple iterable arguments

Value

iteror that iterates through each argument in sequence

Author

Peter Meilstrup

Examples

it <- i_chain(1:3, 4:5, 6)
as.list(it)
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 2
#> 
#> [[3]]
#> [1] 3
#> 
#> [[4]]
#> [1] 4
#> 
#> [[5]]
#> [1] 5
#> 
#> [[6]]
#> [1] 6
#> 

it2 <- i_chain(1:3, levels(iris$Species))
as.list(it2)
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 2
#> 
#> [[3]]
#> [1] 3
#> 
#> [[4]]
#> [1] "setosa"
#> 
#> [[5]]
#> [1] "versicolor"
#> 
#> [[6]]
#> [1] "virginica"
#>