tags:

views:

77

answers:

2

can anyone tell me whats the algorithm used for this function:

http://stat.ethz.ch/R-manual/R-devel/library/utils/html/combn.html ? I want to implement the same for php, so any pointers to php implementation of the same function would also be helpful. Thanks.

+1  A: 

http://stackoverflow.com/questions/1435552/php-array-combination

Mark Baker
thanks for the link. although, I read that combn algorithm in R is very efficient and would appreciate if you (or someone else) can point to that algorithm (I can't access the book right now..)
+2  A: 

It appears that combn is implemented in R, so you can see the code by typing combn <Enter>

It begins

function (x, m, FUN = NULL, simplify = TRUE, ...) 
{
    stopifnot(length(m) == 1L)
    if (m < 0) 
....

This is not the forum to copy and paste source code, but you can very easily see the code.

Greg
thanks, having never used R before, that's exactly what I needed to know.