Re: Debugging Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg94736] Re: Debugging Mathematica
- From: m.r at inbox.ru
- Date: Mon, 22 Dec 2008 05:16:28 -0500 (EST)
- References: <gig3ms$2fg$1@smc.vnet.net>
Nikolaus Rath wrote: > Hello, > > I have trouble debugging a function that I wrote. The function is of the = > form > > f[x_,y_] := Module[{a,b}, ...] > > I am able to set a breakpoint in the function and Mathematica > correctly stops execution. > > However, now I want to inspect the state of some local variables. > Unfortunately some of them have very large contents (~500 000 reals), > so when I open the stack and try to expand the "Local Variables" cell, > the frontend just hangs. > > Is there a way to *selectively* display some of the local variables? > What I would like most is to be able to execute code in the current > stack frame, e.g. if I could simply evaluate a[[1]] in some notebook > to get the first element of the local variable a. Is that possible? > > I am using Mathematica 7. > > Best, > > -Nikolaus > > -- > =C2=BBIt is not worth an intelligent man's time to be in the majority. > By definition, there are already enough people to do that.=C2=AB > -J.H. Hardy > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C Module renames the local variables, so you need to know their actual names. Suppose you have Module[{a, b}, ...]; when a breakpoint is hit type in a$ and then press Control-K (Complete Selection) to see the symbols whose names start with a$ (or evaluate Names["a$*"]). Chances are that the one with the largest number is the current one. If you evaluate a$n, it will be stored in In[], so you may want to Clear or Remove a$n later, otherwise it will not be freed because there is a link to it. Maxim Rytin m.r at inbox.ru