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

MathGroup Archive 2010

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

Search the Archive

Re: Obtaining information about function definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114812] Re: Obtaining information about function definitions
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 17 Dec 2010 23:48:08 -0500 (EST)

f["abc"][x_] := 1;
f["def"][x_] := 2;
f["ghi"][x_] := 3;

Cases[SubValues[f], f[str_][_] :> str, 3]

{"abc", "def", "ghi"}


Bob Hanlon

---- ntg <ntgladd at gmail.com> wrote: 

=============
Suppose I have defined a set of functions associated with symbol f and
indexed by strings, for example

f["abc"][x_] := 1;
f["def"][x_] := 2;
f["ghi"][x_] := 3;
...

I would like to write a program that defines a new set of functions
associated with g and indexed by the same strings.

How can I obtain a list of all the strings that have been used as
indexes of f? Both Information[f] and Definition[f] result in output
that "shows" me the information I seek. But I can't access and
manipulate that information. There must be a way to do this. Can
anyone help?

Thanks,
Tom



  • Prev by Date: Re: NMinimize::nrnum:
  • Next by Date: Re: TextRecognize tabular data
  • Previous by thread: Re: Obtaining information about function definitions
  • Next by thread: Maximum likelihood and experimental data