Learn R Programming

iterors (version 1.0)

idedup: Drop duplicated items from an iterator.

Description

Constructs an iterator that removes runs of repeated elements from the underlying iterator. Order of the elements is maintained. Only the element just seen is remembered for determining whether to drop.

Usage

idedup(object, cmp = identical, ...)

Value

an iterator that skips over duplicate items from teh unterlying iterator.

Arguments

object

an iterable object

cmp

A function to use for comparison.

...

passed along to iteror(object, ...)

Details

Originated as itertools2::iunique_lastseen. object.

See Also

i_rle

Examples

Run this code
it <- i_chain(rep(1,4), rep(2, 5), 4:7, 2)
it_i_unique <- idedup(it)
as.list(it_i_unique) # 1 2 4 5 6 7 2

it2 <- iteror(c('a', 'a', "A", 'a', 'a', "V"))
i_dedupe <- idedup(it2)
as.list(idedup) # a A a V

Run the code above in your browser using DataLab