Some General Notations and Conventions

Function Names

The names of built-in functions follow some general guidelines.

Function Arguments

The main expression or object on which a built-in function acts is usually given as the first argument to the function. Subsidiary parameters appear as subsequent arguments.

The following are exceptions:

For mathematical functions, arguments that are written as subscripts in standard mathematical notation are given before those that are written as superscripts.

Options

Some built-in functions can take options. Each option has a name, represented as a symbol, or in some cases a string. Options are set by giving rules of the form name->value or name:>value. Such rules must appear after all the other arguments in a function. Rules for different options can be given in any order. If you do not explicitly give a rule for a particular option, a default setting for that option is used.

Operations on options.

Part Numbering

Numbering of parts.

Sequence Specifications

Specifications for sequences of parts.

The sequence specification {m,n,s} corresponds to elements m, m+s, m+2s, …, up to the largest element not greater than n.

Sequence specifications are used in the functions (RefLink[Drop, paclet:ref/Drop]), (RefLink[Ordering, paclet:ref/Ordering]), (RefLink[StringDrop, paclet:ref/StringDrop]), (RefLink[StringTake, paclet:ref/StringTake]), (RefLink[Take, paclet:ref/Take]), and (RefLink[Thread, paclet:ref/Thread]).

Level Specifications

Level specifications.

The level in an expression corresponding to a non-negative integer n is defined to consist of parts specified by n indices. A negative level number -n represents all parts of an expression that have depth n. The depth of an expression, (RefLink[Depth, paclet:ref/Depth])[expr], is the maximum number of indices needed to specify any part, plus one. Levels do not include heads of expressions, except with the option setting (RefLink[Heads, paclet:ref/Heads])->(RefLink[True, paclet:ref/True]). Level 0 is the whole expression. Level -1 contains all symbols and other objects that have no subparts.

Ranges of levels specified by {(Subscript[n, 1]),(Subscript[n, 2])} contain all parts that are neither above level (Subscript[n, 1]), nor below level (Subscript[n, 2]) in the tree. The (Subscript[n, i]) need not have the same sign. Thus, for example, {2,-2} specifies subexpressions that occur anywhere below the top level, but above the leaves, of the expression tree.

Level specifications are used by functions such as (RefLink[Apply, paclet:ref/Apply]), (RefLink[Cases, paclet:ref/Cases]), (RefLink[Count, paclet:ref/Count]), (RefLink[FreeQ, paclet:ref/FreeQ]), (RefLink[Level, paclet:ref/Level]), (RefLink[Map, paclet:ref/Map]), (RefLink[MapIndexed, paclet:ref/MapIndexed]), (RefLink[Position, paclet:ref/Position]), (RefLink[Replace, paclet:ref/Replace]), and (RefLink[Scan, paclet:ref/Scan]). Note, however, that the default level specifications are not the same for all of these functions.

Iterators

Iterator notation.

Iterators are used in such functions as (RefLink[Sum, paclet:ref/Sum]), (RefLink[Table, paclet:ref/Table]), (RefLink[Do, paclet:ref/Do]), and (RefLink[Range, paclet:ref/Range]).

The iteration parameters (Subscript[i, min]),(Subscript[i, max]) and di do not need to be integers. The variable i is given a sequence of values starting at (Subscript[i, min]), and increasing in steps of di, stopping when the next value of i would be greater than (Subscript[i, max]). The iteration parameters can be arbitrary symbolic expressions, so long as ((Subscript[i, max])-(Subscript[i, min]))/di is a number.

When several iteration variables are used, the limits for the later ones can depend on the values of earlier ones.

The variable i can be any symbolic expression; it need not be a single symbol. The value of i is automatically set up to be local to the iteration function. This is effectively done by wrapping a (RefLink[Block, paclet:ref/Block]) construct containing i around the iteration function.

The procedure for evaluating iteration functions is described in "Evaluation".

Scoping Constructs

Scoping constructs in the Wolfram Language. Functions in the first group scope variables lexically.

Scoping constructs allow the names or values of certain symbols to be local.

Some scoping constructs scope lexically, meaning that literal instances of the specified variables or patterns are replaced with appropriate values. When local variable names are required, symbols with names of the form xxx are generally renamed to xxx$. When nested scoping constructs are evaluated, new symbols are automatically generated in the inner scoping constructs so as to avoid name conflicts with symbols in outer scoping constructs.

When a transformation rule or definition is used, (RefLink[ReplaceAll, paclet:ref/ReplaceAll]) (/.) is effectively used to replace the pattern names that appear on the right-hand side. Nevertheless, new symbols are generated when necessary to represent other objects that appear in scoping constructs on the right-hand side.

Each time it is evaluated, (RefLink[Module, paclet:ref/Module]) generates symbols with unique names of the form xxx$nnn as replacements for all local variables that appear in its body.

(RefLink[Block, paclet:ref/Block]) localizes the value of global variables. Any evaluations in the body of a block which rely on the global variable will use the locally specified value even if the variable does not explicitly appear in the body, but is only referenced through subsequent evaluation. The body of the (RefLink[Block, paclet:ref/Block]) may also make changes to the global variable, but any such changes will only persist until the (RefLink[Block, paclet:ref/Block]) has finished executing.

(RefLink[DynamicModule, paclet:ref/DynamicModule]) localizes its variables to each instance of the (RefLink[DynamicModule, paclet:ref/DynamicModule]) output in a notebook. This means each copy of a (RefLink[DynamicModule, paclet:ref/DynamicModule]) output created using copy and paste will use its own localized variables.

Ordering of Expressions

The canonical ordering of expressions used automatically with the attribute (RefLink[Orderless, paclet:ref/Orderless]) and in functions such as (RefLink[Sort, paclet:ref/Sort]) satisfies the following rules:

Ordinary letters appear first, followed in order by script, Gothic, double-struck, Greek and Hebrew. Mathematical operators appear in order of decreasing precedence.

Mathematical Functions

The mathematical functions such as (RefLink[Log, paclet:ref/Log])[x] and (RefLink[BesselJ, paclet:ref/BesselJ])[n,x] that are built into the Wolfram Language have a number of features in common.

Mathematical Constants

Mathematical constants such as (RefLink[E, paclet:ref/E]) and (RefLink[Pi, paclet:ref/Pi]) that are built into the Wolfram Language have the following properties:

Protection

The Wolfram Language allows you to make assignments that override the standard operation and meaning of built-in Wolfram Language objects.

To make it difficult to make such assignments by mistake, most built-in Wolfram Language objects have the attribute (RefLink[Protected, paclet:ref/Protected]). If you want to make an assignment for a built-in object, you must first remove this attribute. You can do this by calling the function (RefLink[Unprotect, paclet:ref/Unprotect]).

There are a few fundamental Wolfram Language objects to which you absolutely cannot assign your own values. These objects carry the attribute (RefLink[Locked, paclet:ref/Locked]), as well as (RefLink[Protected, paclet:ref/Protected]). The (RefLink[Locked, paclet:ref/Locked]) attribute prevents you from changing any of the attributes, and thus from removing the (RefLink[Protected, paclet:ref/Protected]) attribute.

Abbreviated String Patterns

Functions such as (RefLink[StringMatchQ, paclet:ref/StringMatchQ]), (RefLink[Names, paclet:ref/Names]), and (RefLink[Remove, paclet:ref/Remove]) allow you to give abbreviated string patterns, as well as full string patterns specified by (RefLink[StringExpression, paclet:ref/StringExpression]). Abbreviated string patterns can contain certain metacharacters, which can stand for sequences of ordinary characters.

Metacharacters used in abbreviated string patterns.