ipairwise: Iterator that returns elements of an object in pairs

Description Usage Arguments Value Examples

Description

Constructs an iterator of an iterable object that returns its elements in pairs.

Usage

1
ipairwise(object)

Arguments

object

an iterable object

Value

an iterator that returns pairwise elements

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
it <- ipairwise(iterators::iter(letters[1:4]))
iterators::nextElem(it) # list("a", "b")
iterators::nextElem(it) # list("b", "c")
iterators::nextElem(it) # list("c", "d")

it2 <- ipairwise(1:5)
iterators::nextElem(it2) # list(1, 2)
iterators::nextElem(it2) # list(2, 3)
iterators::nextElem(it2) # list(3, 4)
iterators::nextElem(it2) # list(4, 5)

itertools2 documentation built on May 2, 2019, 3:37 p.m.