iperm: Permutation Iterator

View source: R/iperm.R

ipermR Documentation

Permutation Iterator

Description

Create an iterator for all permutations of size k of integers 1 to n.

Usage

iperm(n, k = n)

ipermv(values, k = length(values))

Arguments

n

positive integer

k

positive integer

values

iterable (subsettable by [)

Details

  • iperm iterates through integer vectors

  • ipermv iterates through general values

Value

iterator object

Examples

x <- iperm(3)
ct <- 0
while (hasNext(x))
{
  ct <- ct + 1
  i <- nextElem(x)
  cat(sprintf("%3d : %s\n", ct, paste0(i, collapse = " ")))
}


as.list(ipermv(c("R", "G", "B")))

kota7/combiter documentation built on June 14, 2025, 11:08 a.m.