Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Can't read a package
Replies: 3   Last Post: Nov 28, 2010 6:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James Stein

Posts: 12
Registered: 8/12/10
Can't read a package
Posted: Nov 26, 2010 5:29 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am very frustrated that, after a year with Mathematica, I still cannot
create and use packages. I must be missing something elementary.

Here is what I have attempted. I think there is just one missing part:

Step 1: "write" a package:
In the tutorial "Setting Up Mathematica Packages" there is source for the
sample package "Collatz.m". I copied that source and pasted it into a new
Mathematica file, then used the "Save As" command to save the file as a
package, naming it "collatz.m" and placing it in a folder called packages.

Step 2: Try to use the package:
1. I create a new Mathematica notebook file, put the following five lines in
it, and save it as "collatz.nb" alongside "collatz.m":

SetDirectory["~/desktop/MathNoteBooks/packages"];
FileNames[]
PrependTo[$Path, Directory[]]
(* missing step; neither << collatz.m nor Import["collatz.m"] works *)
Collatz[5] (* 'Collatz' remains undefined *)


Missing Step:
Executing the above code, the output from "FileNames" shows that both files
exist in the directory. So what code should replace the fourth line above?
Or have I gone astray elsewhere?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.