Skip to content
Prev 46184 / 63461 Next

The *tmp* variable

Peter:

(Your function doesn't work -- you need to specify runif(1))

What ambiguity?

In the assignment within f(), x <- x+1,

the "x" on the rhs is a free variable in the function, and is
therefore looked for in the environment where the function was
defined. The x on the lhs is defined within the function only.

No matter what f() returns, x remains 1 in the environment from which
f is called. The function does not "return x" -- it returns a value,
which you can assign as you wish.

So ???
(and apologies if I'm missing something obvious).

Cheers,
Bert

On Sat, Jul 6, 2013 at 9:11 PM, Peter Meilstrup
<peter.meilstrup at gmail.com> wrote: