Everything Is an Expression

The Wolfram Language handles many different kinds of things: mathematical formulas, lists, and graphics, to name a few. Although they often look very different, the Wolfram Language represents all of these things in one uniform way. They are all expressions.

A prototypical example of a Wolfram Language expression is f[x,y]. You might use f[x,y] to represent a mathematical function f(x,y). The function is named f, and it has two arguments, x and y.

You do not always have to write expressions in the form f[x,y,…]. For example, x+y is also an expression. When you type in x+y, the Wolfram Language converts it to the standard form (RefLink[Plus, paclet:ref/Plus])[x,y]. Then, when it prints it out again, it gives it as x+y.

The same is true of other "operators", such as ^ ((RefLink[Power, paclet:ref/Power])) and / ((RefLink[Divide, paclet:ref/Divide])).

In fact, everything you type into the Wolfram Language is treated as an expression.

Some examples of Wolfram Language expressions.

You can see the full form of any expression by using (RefLink[FullForm, paclet:ref/FullForm])[expr].

Here is an expression:

x+y+z

This is the full form of the expression:

FullForm[%]

Here is another expression:

1+x^2+(y+z)^2

Its full form has several nested pieces:

FullForm[%]

The object f in an expression f[x,y,…] is known as the head of the expression. You can extract it using (RefLink[Head, paclet:ref/Head])[expr]. Particularly when you write programs in the Wolfram Language, you will often want to test the head of an expression to find out what kind of thing the expression is.

(RefLink[Head, paclet:ref/Head]) gives the "function name" f:

Head[f[x,y]]

Here (RefLink[Head, paclet:ref/Head]) gives the name of the "operator":

Head[a+b+c]

Everything has a head:

Head[{a,b,c}]

Numbers also have heads:

Head[23432]

You can distinguish different kinds of numbers by their heads:

Head[345.6]

Functions for manipulating expressions.