BeginPackage

BeginPackage["context`"]
makes and the only active contexts.

BeginPackage["context`", {"need1`", "need2`", ...}]
calls Needs on the .

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

Commands to define a simple package:

In[1]:=
Click for copyable input

The context for symbol creation has been changed to :

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

The context path for symbol lookup includes :

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

Here are the commands defining the function in the package:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input

Restore the context, but leave on the context path for symbol lookup:

In[6]:=
Click for copyable input

Since EndPackage leaves on the context path, the function defined is visible:

Get the square of 12:

In[8]:=
Click for copyable input
Out[8]=
New in 1
New to Mathematica? Find your learning path »
Have a question? Ask support »