From giampi at kth.se  Fri Jan 19 14:21:24 2007
From: giampi at kth.se (Giampiero Salvi)
Date: Fri, 19 Jan 2007 14:21:24 +0100 (CET)
Subject: [Rd] combn implementation
Message-ID: <Pine.LNX.4.58.0701191413190.20958@ctt35.speech.kth.se>

Hi,
I was checking the source code to the function combn that "generates
all combinations of the elements of 'x' taken 'm' at a time.",
because I wished to modify it. I have a doubt about a statement.
This is the main loop.

    ._1 <- 1:1
    nmmp1 <- n - m + ._1
    while (a[1] != nmmp1) {
        if (e < n - h) {
            h <- ._1
            e <- a[m]
            j <- ._1
        }
        else {
            e <- a[m - h]
            h <- h + ._1
            j <- 1:h
        }
        a[m - h + j] <- e + j
        r <- if (nofun)
            x[a]
        else FUN(x[a], ...)
        if (simplify)
            out[, i] <- r
        else out[[i]] <- r
        i <- i + 1
    }

I wonder what is the meaning of the statement "._1 <- 1:1".
First question: what is the difference with "._1 <- 1"?
Second question (perhaps answerd by the answer to the first): why not
using "1" directly? E.g.:
[...]
h <- 1
e <- a[m]
e <- 1
[...]

Sorry if this is covered by the manuals, but it's not easy to search
for the string "._1" with the usual search engines.
Thank you!
Giampiero



[Rd] combn implementation
Giampiero Salvi