[S] Using apply with Global variables

Kirthi Kalyanam (kkalyanam@scu.edu)
Wed, 19 Aug 1998 20:59:36 -0700


A question:

Here is a simplification of some code that I am working on:

x_0
myfunction_function(y,x) {
x=x+y
return(y-x)^2
}

z_apply(y,1,funct,x)

The problem is that the value of x needs to be updated each time 'myfunction' is applied. But in the above code x will always be zero. It seems that one approach is to somehow declare x to be a global variable so that it can be changed within 'myfunction'.

How does one declare global variables in S?

Appreciate any other solutions.

Kirthi Kalyanam

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news