Can someone offer some tips on how to get started with math packages?
I can save the following in a file called "Foo.m". When I run the input cell in this file, I see the effects reflected in the $ ContextPath variable.
BeginPackage["Foo`"]
bar::usage = "barfunction";
Begin["`private`"]
bar[w_] := w;
End[];
EndPackage[];
However, on my laptop I have the following:
SetDirectory[ToFileName[{$HomeDirectory, "My Documents", "mathematica"}]];
Needs["Foo`"]
$ContextPath
But for some reason, the call for some reason does not work, and $ ContextPath remains unchanged.
Edit
I believe that now I have a partial solution, the cell in my file has not been marked as an initialization cell - and so far I can now <<Foo', Needs["Foo"]` still does not work correctly.
source
share