Mathematica Programming » Code Structure

Symbols and Expressions

Symbols

Mathematica has one more basic type than those mentioned before: Symbol

In reality, every variable we've used and function we've defined (excluding pure functions) has been a symbol.

One thing to keep in mind is that the only things that can have properties or values in Mathematica are symbols, although a symbol need not have any.

All of the following are symbols:

 Automatic
AxesLabel
$ModuleNumber
Rule
SetDelayed
 Automatic
 AxesLabel
 1205
 Rule
 SetDelayed

Expressions

In Mathematica, they say everything is an expression. What this means, really, is that outside of the primitive types everything has one common form:

 (head)[arg1,arg2,arg2,...,argn]

Furthermore, there are tools to parse these structures:

 {1,2,3}//FullForm
 List[1,2,3]

This even applies to things like graphics. Consider the following graphic:

 Graphics3D[Sphere[],Boxed->False,Lighting->"Neutral",ImageSize->Small]
211symbolsandexpressions-7059428318388094490

It is, however, still just an expression:

 Graphics3D[Sphere[], Boxed->False, Lighting->"Neutral", ImageSize->Small ]//FullForm
 Graphics3D[Sphere[List[0,0,0]],Rule[Boxed,False],Rule[Lighting,"Neutral"],Rule[ImageSize,Small]]