The "At" Object

The At object in the Core namespace is used to specify the location of child term inside of a parent expression. The At object is capable of defining the location of any term in an expression no matter how many levels down in the expression tree it's located. The At object is commonly used with commands that act on the highlighted term in an expression.

The At object is normally rendered as @[a, b, …] and the parameters of the At object are Integers. Each parameter of the At object corresponds to one more level down in the tree. The parameter numbers are zero based, so the location of the first parameter in an expression is always @[0].

In the expression "| x + y |", the following locations are valid:

Location Expression
@[ ] | x + y |
@[0] x + y
@[0, 0] x
@[0, 1] y
The GetTerm function can be used to get the term at a specified location. So in the example above, GetTerm[ | x + y |, @[0]] will return the expression "x + y". For the expression in the example, the GetTerm function will return null for any location other than the ones in the table.

The At object is a monoid. This means that in an expression like:

{ @[0, 0, 0] => @[m..., n] }

are valid and the variable "m" is bound to @[0, 0], which is the parent of the term identified by the original location expression. Patterns like this allow construction of functionality that recursively walks up the expression tree. The Move command uses this approach to go up the expression tree looking for an Equal object so it can move the highlight to the other side of the equality.

In the pattern match:

{ @[0, 0] => @[k, m, n...] }

the variable "n" is bound to @[], the zero parameter At object, which refers to location of the whole expression. The result from calling GetTerm[expr, @[]] is always just "expr".