Wolfram Research has Tutorial Collection for free download in PDF (of
course, you can buy printed book from same place):
http://www.wolfram.com/learningcenter/tutorialcollection/
I beleive that there you can find everything you need.
--
== Matemati=E8ko podzemlje ==
http://www.matematicko-podzemlje.com/
http://matka.forumotion.com/
http://www.travian.com.hr/?uc=hr3_5588
Needs["packagefolder`packagename`"]
Then to obtain the exported names in the package use:
?packagefolder`packagename`*
That will list all the names and when you click on one of the names it will
display the corresponding usage message.
For example, to obtain the names in one of the standard extra packages that
come with Mathematica (these don't have their own folder):
Needs["ComputationalGeometry`"]
?ComputationalGeometry`*
The Presentations package distribution has a small sample package notebook
with detailed commentary on how to write and set up you own package. The
entire process is quite easy.
Basically you set up your package as follows:
1) Find, or create, an Applications folder in your $UserBaseDirectory
folder.
2) In this private Applications folder create a folder packagefolder
(whatever name you choose) to contain your package.
3) Write a notebook, packagename.nb (whatever name you choose), that will be
your package definition notebook. It will contain all the Package
statements, usage statements and routine definitions. Make these
Initializations cells.
4) When you first save (in the regular way) the packagename.nb it will ask
you if it to be saved as an Auto Generated Package. Answer yes. This will
create a packagename.m package file. Every time you update packagename.nb,
packagename.m will also be automatically updated. You should never have to
look at the contents of packagename.m.
5) You load the package as above.
Probably the best book on programming and writing packages is "Programming
in Mathematica: Third Edition" by Roman Maeder. But this was written for
Version 3 and contains no information on where to put packages. This was
quite unsettled at the time. The question of where to put and how to load
packages is confusing to most users first writing packages because I don't
know of any easily accessible place where it is discussed in the Mathematica
documentation.
You can also import you package code into Workbench and then write Version 6
style documentation. This is not too difficult either, once you learn the
tricks, but the documentation and convenience of Workbench is very poor at
the present time. This is a shame because Workbench could be great for
writing interactive electronic books, or courseware or doing major research
projects that contained notebooks, packages and documentation. But this is a
whole different topic.
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
If you followed the usual way of constructing the package, then all
the public symbols of the package (and *only* the public symbols of
the package) will be in a context associated with it.
Thus Names["MyPackagesContext`*"] is going to return a list of the
names of the symbols in the package. (?MyPackagesContext`* is probably
more convenient for a user of the package.)
Take a look at how some of the standard packages are organized.
First comes BeginPackage["MyPackage`"], then all the symbols (and only
those symbols) that are to be exported by the package are mentioned
(usually in the form of usage message definitions), then comes a Begin
["`Private`"] followed by the actual definitions of the functions.
This structure ensures that the symbols that are meant for public use
are part of MyPackage` and the rest of the symbols used in the
function definitions are private.
>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.
First, load the package using either Get or Needs. Then doing
?contextname`* will list all of the symbols available to the
user where contextname is the name of the context for the
package loaded. Usually (not always), this is the same as the
package name. For example, if I load a package I've created for
my usage by doing:
In[1]:= << Statistics`SplineSmoothing`
In[2]:= ?Statistics`SplineSmoothing`*
Statistics`SplineSmoothing`
EDF NaturalSpline SplinePolynomial
MonotonicQ SplineD SplineResiduals
MonotonicSmoothing SplineEvaluate SplineRoot
I get a list of functions in the package
>b. According to you what are the best references to study the theme
>of packages in Mathematica?
Maeder has written a couple of texts on programming in
Mathematica that would make a good starting point. But even
without using Maeder's books, simply opening packages that are
distributed with Mathematica with a text editor to see how they
are written can be quite informative.
a)
what may
Names["mypackage`*"]
do ? Print all the symbols in that context ?
b) is it so much to study ? "Programming in Mathematica" by Roman Maeder
Regards
Jens
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 <fgutie...@yahoo.com