Skip to content

The *tmp* variable

4 messages · Bert Gunter, Peter Meilstrup

#
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:

  
    
#
Thanks, Peter. Now I get it.

It _was_ obvious!

-- Bert

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