Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: List of patterns for which a function is defined?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24409] Re: List of patterns for which a function is defined?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 18 Jul 2000 00:58:08 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <8kjdh1$du2@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

ListOfPatternsDefined[a_Symbol] :=
   First /@ DownValues[a] /. a[arg_] :> arg /.
Verbatim[HoldPattern][val_] :> val

will do it

Regards
  Jens



Roger Wilson wrote:
> 
> I have a function b which I define explicitly for a set of input values.
> 
> a[1]=4; a[2]=5; a["cat"]="sam";
> 
> If I type ??a I get the usual listing of the definition of a but how do I
> get a list of the values or patterns for which a is defined?
> 
> ListOfPatternsDefined[a]
> {1,2,"cat"}
> 
> In python this would be a.keys() but in Mathematica I'm stuck?
> 
> Any ideas?
>


  • Prev by Date: ?symbol and Context[symbol] Together even in Presence of Usage
  • Next by Date: Bessel function replacement rules
  • Previous by thread: List of patterns for which a function is defined?
  • Next by thread: Re: List of patterns for which a function is defined?