Displaying 1 result from an estimated 1 matches for "multiply_by_y".
2012 Aug 06
3
Force evaluation of a symbol when a function is created
I am porting a program in matlab to R,
The problem is that Matlab has a feature where symbols that aren't arguments are evaluated immediately.
That is:
Y=3
F=@(x) x*Y
Will yield a function such that F(2)=6.
If later say. Y=4 then F(2) will still equal 6.
R on the other hand has lazy evaluation.
F<-function(x){x*Y}
Will do the following
Y=3
F(2)=6
Y=4
F(2)=8.
Does anyone know of away to