According to Mathematica, everything is an expression. So an atom is also an expression. But in other parts of documentation, they say that an expression is of form Head[e1,e2,..]
. This is a contradiction since an atom does not have that form. Confused.
To express more clearly what I mean look at the following statements.
An atom is an expression.
All expressions have the form Head[e1,e2,..]
Expressions of type Head[e1,e2,..] have parts
An atom does not have parts.
These 4 statements are contradictory.
If 2. would say that Some expressions have the form Head[e1,e2,..], then there would not be a problem. Then we could say that some expressions are atomic (like number 7) and some (like Plus[2,3] are nested (or molecular or whatever is the right word).
In that case I would express the whole situation as follows:
We should distinguish between two types of expressions: atomic expressions and nested expressions.
An expression is a tree structure. An atom is leaf ( a node with no children) while nested expressions have also branches (a node with children).
Mathematica comes with a bunch of primitive elements. About a dozen atoms (like numbers, strings, etc) and several thousends of built in functions (like Plus, Plot, Module, etc).
The main purpose of nested expressions is to COMBINE atoms and other nested expressions into new expressions. Since an argument of a nested expression can itself be an expression it gives us enormous combinatorial power to build new expressions (that themselves can behave like built in functions, inside our session, or otherwise taking proper care to put them into packages that can be imported).
e0[e1, e2, ...]
, where each ofe0
,e1
, ..., is itself an expression. Sometimes atoms are shown as if they were compound, e.g.Complex[1,2]
, but you can think of this as just an illusion. They are still atoms.Head
returns a result for every expression, even atoms. This does not mean that atoms have a separate, extractable head. It's just a data type marker. $\endgroup$CompoundExpressions
themselves non-atomic expressions? (Also, I think @Szabolcs was referring to all non-atomic expressions when saying 'compound expressions' -- it seems natural (at least in English) to refer to something non-atomic as 'compound', but alas MMA already usesCompoundExpression
. Ah, the imprecision of human language!) $\endgroup$Rational
andComplex
) are divisible! $\endgroup$