The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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":

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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.