Re: Can't read a package

*To*: mathgroup at smc.vnet.net*Subject*: [mg114216] Re: Can't read a package*From*: juan flores <juanfie at gmail.com>*Date*: Sat, 27 Nov 2010 03:37:49 -0500 (EST)*References*: <ico262$njg$1@smc.vnet.net>

On Nov 26, 4:29 am, James Stein <ja... at stein.org> wrote: > 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? Try this: http://lsc.fie.umich.mx/~juan/Materias/Cursos/Mathematica7.0/Notas7.0/12Packages.nb It was collected from several sources and taken to work on Mathematica 7.0 Cheers, Juan