help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Functions inhereting variables


From: Mike B.
Subject: Functions inhereting variables
Date: Thu, 18 Nov 2010 18:09:42 -0800 (PST)

Hi all,

Is it possible to define a function which `inherits' variables from the scope 
it was called from without explicity passing them for example:

function out = f( x )
   out = x + a + b;
endfunction

and in the main code:
a=1
b=2
f( 3 ) 
would give 6

Anonymous functions can inherit variables but they seem limited to simple 
1-line codes. 

Thanks,
Mike.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]