icomb: Combination Iterator

Description Usage Arguments Details Value Examples

Description

Create an iterator for all combinations k integers out of 1 through n.

Usage

1
2
3
icomb(n, k)

icombv(values, k)

Arguments

n

positive integer

k

positive integer no greater than n

values

iterable (subsettable by [)

Details

Value

iterator object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- icomb(5, 3)
ct <- 0
while (hasNext(x))
{
  ct <- ct + 1
  i <- nextElem(x)
  cat(sprintf("%3d : %s\n", ct, paste0(i, collapse = " ")))
}

as.list(icombv(c("A", "G", "C"), 2))

kota7/combiter documentation built on May 20, 2019, 1:10 p.m.