s-news
[Top] [All Lists]

[S] Using apply with Global variables

To: s-news@wubios.wustl.edu
Subject: [S] Using apply with Global variables
From: "Kirthi Kalyanam" <kkalyanam@scu.edu>
Date: Wed, 19 Aug 1998 20:59:36 -0700
Sender: owner-s-news@wubios.wustl.edu
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

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Using apply with Global variables, Kirthi Kalyanam <=