Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: local variables

  • To: mathgroup at
  • Subject: Re: local variables
  • Date: 29 Sep 1992 22:44:12 -0700 (MST)

John Pender (tuk at asks:
>  hi guys-
>  i'm forwarding an inquiry from one of my students.  in particular, is there
>  an mma function that returns a list of all the variables you've defined in a
>  session and their values?  thanks in advance.
The function Names["Global`*"] will return a list of the names (as strings) of
all variables defined in the Global` context. From there, you can do what you
want. For example, for a primitive printout of variables and values, you could
Print[# <> " = " <> ToString[ToExpression[#]]]& /@ Names["Global`*"];
This won't show the definitions of functions, however. For example, if you have
defined f[x_] := something, then the printout will include the line
f = f
because the symbol f, all by itself, has not been given a value. An alternative
is to use
(Print[#]; Information[#]; Print["\n"])& /@ Names["Global`*"];
This will show more about each symbol, including defs for functions, but it is
much slower.
Todd Gayley
Department of Ecology and Evolutionary Biology
University of Arizona
tgayley at       -or-        tgayley at

  • Prev by Date: metafiles
  • Next by Date: Mma bibliography
  • Previous by thread: local variables
  • Next by thread: Uses in h.s.APcalculus