From p.dalgaard@biostat.ku.dk  Fri Apr 20 13:48:33 2001
From: p.dalgaard@biostat.ku.dk (p.dalgaard@biostat.ku.dk)
Date: Fri, 20 Apr 2001 14:48:33 +0200 (MET DST)
Subject: [Rd] Re: Precedence of %% (PR#879)
Message-ID: <200104201248.OAA13781@pubhealth.ku.dk>


This message from Duncan M. (listed below) seems to have escaped the
r-devel list, possibly due to lack of a subject header.

gram.y has

...
%left           '*' '/' '%'
%left           SPECIAL
%left           ':'
...

and %% is a SPECIAL token, so it does indeed have higher precedence
than *. This is somewhat unusual compared to other languages, but it
is compatible with S-PLUS 3.4, so I'd say that it is the documentation
that is wrong. (And that part was written by me, I'm afraid...)

	-p



Date: Sun, 18 Mar 2001 07:45:13 -0500 (EST)
From: Duncan Murdoch <murdoch@stats.uwo.ca>
To: r-bugs@r-project.org

According to the documentation (R-lang p. 56), * 
and %% (mod) have equal operator precedence, so they 
should group from left to right.  Thus

  3 * 4 %% 5

should give 2, i.e. (3*4) mod 5.  However, I get 

 >   3 * 4 %% 5
 [1] 12

i.e. 3 * (4 mod 5).

Other experiments suggest to me that %% is given 
higher priority than *, it's not the "left to right" 
rule that is not being followed.

Duncan Murdoch



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Re: Precedence of %% (PR#879)
p.dalgaard@biostat.ku.dk