idedup {iterors}R Documentation

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, ...)

Arguments

object

an iterable object

cmp

A function to use for comparison.

...

passed along to iteror(object, ...)

Details

Originated as itertools2::iunique_lastseen. object.

Value

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

See Also

i_rle

Examples

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


[Package iterors version 1.0 Index]