Re: [R] functional (?) programming in r

From: Stavros Macrakis <>
Date: Mon, 17 Nov 2008 22:44:47 -0500

On Mon, Nov 17, 2008 at 7:33 PM, Wacek Kusnierczyk <> wrote:
> Gabor Grothendieck wrote:
>> The R Language Definition manual that comes with R has a section on promises.


> on promises yes, but the question was whether the behaviour discussed
> before is obvious and intended, or unforeseen....


> ...what i would (r-naively) expect is that lapply for-loops over an index variable, and each promise picks from the list a value at that index....

Agreed. In fact, the man page for 'for' seems to explicitly specify that the iteration variable is not mutable: "The variable var... is read-only". However, the implementation doesn't seem to enforce this:

      for (i in 1:5) print(i<-i) # no error given for this assignment

           -s mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 18 Nov 2008 - 03:49:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Nov 2008 - 12:30:26 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive