R/allFree.R

Defines functions `allFree`

## Modified version of allFree() provided by Doug Bates
## via personal email on 19 Jan 2012
`allFree` <- function(n, v = seq_len(n)) {
    if(n == 1L) return(array(v, c(1L, 1L)))
    do.call(rbind,
            lapply(seq_len(n),
                   function(i) cbind(v[i], allFree(n - 1L, v[-i]))))
}

Try the permute package in your browser

Any scripts or data that you put into this service are public.

permute documentation built on March 18, 2022, 7:36 p.m.