Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

function local/private to another function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110586] function local/private to another function?
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Sat, 26 Jun 2010 08:41:15 -0400 (EDT)
  • Reply-to: nma at 12000.org

Hello;

What is the best way to have a function which can only be "seen" and 
called by only the enclosing parent function? And not be in the global 
space (without using a package?).

Is it something like:

f1[x_]:=Module[{b,f2},
     ....
     f2[y_]:=Module[{c},...c=y^2...Return[x]];
     b=f2[x]
     ...
]

But in the above, "c" is not really local to f2, but local to f1 also, 
because I can't write

f1[x_]:=Module[{c,f2},
     ....
     f2[y_]:=Module[{c},...];--> Mathematica complain about "c" here
     ...
]

I Wanted to find what is the best way to have a local function, with its 
own local variables inside a parent function, where the only interaction 
between the inner function and the parent function is via the argument 
call. I looked at Block and With, but they do not do what I need. I 
think Module is the only choice left?  Or should I not bother about 
having local functions to another functions at all and leave everything 
in the global space?

thanks,
--Nasser



  • Prev by Date: Re: Sum of terms --> list
  • Next by Date: Particle Filters
  • Previous by thread: Re: and sampling a distribution
  • Next by thread: Re: function local/private to another function?