Put Wolfram Language definitions in a standalone file to be reused or shared.

Create a new package file

Choose File New Package to create a new package file:

Add boilerplate package commands

Packages have a standard structure that follows this schema. Replace MyPackage with the name of your package:

Add definitions

Public definitions in a package are available for use when a package is loaded. Private definitions are used only internally in a package, not exposed externally.

Add both private and public definitions between Begin[`Private`] and End[].

Add usage messages for public definitions between BeginPackage[...] and Begin["`Private`"]:

Save the package

Choose File Save... and specify the package name:

Use the package

Load a package using << (Get):

In[1]:=
Click for copyable input

After the package is loaded, you can use the public functions defined in it:

In[2]:=
Click for copyable input
Out[2]=

Create a new package file

Select File New Package to create a new package file:

  • The new package file is automatically saved as an unnamed file.

Add boilerplate package commands

Packages have a standard structure that follows this schema. Replace MyPackage with the name of your package:

Add definitions

Public definitions in a package are available for use when a package is loaded. Private definitions are used only internally in a package, not exposed externally.

Add both private and public definitions between Begin[`Private`] and End[].

Add usage messages for public definitions between BeginPackage[...] and Begin["`Private`"]:

Name the package

Click (unnamed) to name the package:

Use the package

Load a package using << (Get). After the package is loaded, you can use the public functions defined in it: