[R] functional (?) programming in r
macrakis at alum.mit.edu
Tue Nov 18 04:44:47 CET 2008
On Mon, Nov 17, 2008 at 7:33 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> 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
More information about the R-help