Re: removing those annoying $$$$'s from local variables names?
- To: mathgroup at smc.vnet.net
- Subject: [mg79702] Re: removing those annoying $$$$'s from local variables names?
- From: Mark Westwood <markc.westwood at gmail.com>
- Date: Thu, 2 Aug 2007 03:49:46 -0400 (EDT)
- References: <f8pk78$2i1$1@smc.vnet.net>
Q: What should one do in this case ? A: Learn to love the way Mathematica displays local variable names when they are exposed outside the scope of their definition. Q: In what sense is it a problem that a function returns a symbol with some minimally cryptic name-mangling ? A: _________________________________________________________________________________________ Regards Mark Westwood On 1 Aug, 10:36, Nasser Abbasi <n... at 12000.org> wrote: > Hello; > > This is a problem I am sure many have seen. May be there is a simple > solution for it, but I can't find it. > > This problem is when a function returns back a symbol which is local > to the function, then these synbols will have $nnnn tacked to them, > and so when the caller say prints the symbol, it will have those $'s > numbers, which make it annoying to look it and print, say as a table > or such. > > This is an example: > > ------------- example 1 ------------- > > foo[] := Module[{c, k}, > c = Array[k, 3] > ]; > > c = foo[]; > Print[c]; > > {k$76[1], k$76[2], k$76[3]} > -------------------------------------------------- > > You see, since k is local to foo[], then when I print it, I see those $ > $$ signs. > > Only way to remove this $$$'s is to make k global as follows > > ------------------------ example 2 ------------------- > Remove[k]; > foo[] := Module[{c}, > c = Array[k, 3] > ]; > > c = foo[]; > Print[c]; > > {k[1], k[2], k[3]} > ---------------------------------------- > > But making 'k' global is something I do NOT want to do, since now I > have to worry about 'k' having a value somewhere else in the code, and > it goes against the whole idea of encapsulation. If I start making all > my symbols global, then the code becomes hard to manage. > > So, what should one do in this case? How can make all the symbols > local to a function, but at the same time not see these $$$'s when the > symbols are used when they are returned from the function back to the > caller? > > thanks, > Nasser