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

MathGroup Archive 2009

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

Search the Archive

Re: two questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100373] Re: [mg100280] two questions
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Tue, 2 Jun 2009 06:43:08 -0400 (EDT)
  • References: <200905311032.GAA16731@smc.vnet.net>

Hi Francisco,

Regarding your first question: the following  should do what you want,
assuming that the package has been loaded.


Clear[functionsInPackage];
functionsInPackage[context_String] :=
  With[{funvalues = {DownValues, UpValues, SubValues}},
   Select[Names[context <> "*"],
    Function[sym,
     Join @@
       Map[ToExpression[sym, InputForm, #] &, funvalues] =!= {}]]];

The result is a list of names (strings). Result will depend on what you mean
by a function - my assumption was that it is any symbol that has one (or
more) of the DownValues, UpValues, SubValues defined for it. You may want to
exclude some of these properties if you need a stricter/different definition
for what constitutes a function.

Regarding the other question: check out "Programming in Mathematica" by
Roman Maeder - this is probably the best source of information on packages.
Another good discussion is in the  book of David Wagner ("Power programming
with Mathematica: the kernel"), but it is out of print. There are also some
recomendations from WRI on writing packages (one by** Todd Gayley if I am
not mistaken), they can be found on MathSource (Wolfram library archive).
Some other books also discuss them but in less detail (Paul Wellin et al,
"Introduction to programming with Mathematica", for instance).
I may also add that I have written a few packages that deal with package
construction issues such as package reloading and symbol dependencies - you
may want to check them out on my web site  <
http://www.mathprogramming-intro.org/additional_resources.html>

Hope this helps.

Regards,
Leonid



On Sun, May 31, 2009 at 3:32 AM, Francisco Gutierrez <fgutiers2002 at yahoo.com
> wrote:

> Dear list members:
>
> a. I made a package and I want to retrieve the functions it has. What I
> would want is:
> Command[mypackage]
> Output: functions for the user contained in myg package
>
> How can I do this? Somehow, I have failed to find this in the
> documentation.
>
> b.  According to you what are the best references to study the theme of
> packages in Mathematica?
> Thanks
> Francisco
>
>


  • Prev by Date: Re: Indexed Slot in a Rule - How to do it??
  • Next by Date: Speeding up code
  • Previous by thread: Re: two questions
  • Next by thread: two questions