Skip to content

Partition of a set

1 message · Michael Bedward

#
Hi Diane,

Does this do what you want ?

listParts <- function(n) {
# Generates a list of lists representing the partitions
# of an integer n
  require(partitions)
  x <- 1:n
  apply(setparts(n), 2, function(pp) tapply(x, pp, function(xx) list(xx)))
}

Michael

On 12 November 2010 21:15, Diana Tichy
<d.tichy at mathematik.uni-wuerzburg.de> wrote: