R/comb.R

Defines functions comb

Documented in comb

comb <-
function(m,n){
lst <- NA
if (m==0 & n==0) return(NULL)
if (m==0) return(matrix(1,1,n))
if (n==0) return(matrix(0,1,m))
k <- min(c(m,n))
for (i in 0:k){
lst <- rbind(lst, concat(comb(i,n-i), comb(m-i,i)))
}
return(lst[-1,])
}

Try the frt package in your browser

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

frt documentation built on May 2, 2019, 6:34 a.m.