R-alpha: Re: terms

Thomas Lumley (thomas@biostat.washington.edu)
Wed, 20 Nov 1996 10:53:44 -0800 (PST)

Date: Wed, 20 Nov 1996 10:53:44 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Ross Ihaka <ihaka@stat.auckland.ac.nz>
Subject: R-alpha: Re: terms
In-Reply-To: <199611200315.QAA20883@stat13.stat.auckland.ac.nz>

The end of one line was missing from the fix. I think the following is 

SEXP applydefine(SEXP call, SEXP op, SEXP args, SEXP rho)
        SEXP expr, lhs, rhs, saverhs, tmp;
        char buf[32];
        expr = CAR(args);
        /* it's important that the rhs get evaluated first */  
        PROTECT(saverhs =rhs = eval(CADR(args), rho));
        PROTECT(lhs = evalseq(CADR(expr), rho, PRIMVAL(op)==1));
        while (isLanguage(CADR(expr))) {
                sprintf(buf, "%s<-", CHAR(PRINTNAME(CAR(expr))));
                PROTECT(rhs = replaceCall(install(buf), CAR(lhs), 
CDDR(expr), rhs));
                rhs = eval(rhs, rho);
                lhs = CDR(lhs);
                expr = CADR(expr);  
        sprintf(buf, "%s<-", CHAR(PRINTNAME(CAR(expr))));
                PROTECT(tmp = lang2(install("expression"), CAR(lhs)));
                PROTECT(tmp = CAR(lhs)); 
        PROTECT(expr = assignCall(install(asym[PRIMVAL(op)]), CDR(lhs),
                                 install(buf), tmp, CDDR(expr), rhs));
        expr = eval(expr, rho);
        return duplicate(saverhs);

r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch