WolframLang: Head of Expression
What is Head of Expression
All WolframLang
Expression,
is either an
Atom
or in the form of
f[a, b, etc]
where the elements are themselves expression.
The f in f[…]
is called the Head of expression.
Get Head of Expression
Head[expr]
-
return the head of expression.
Head of Non-Atomic Expression
Head[ f[x] ] === f
Head[ {3,4} ] === List (* same as *) Head[ List[3,4] ] === List
Head[ x+y ] === Plus (* same as *) Head[ Plus[x,y] ] === Plus
Nested Head
The head itself can be arbitrary expression.
e.g.
in
a[b, c][d, e]
,
the a[b, c]
is the head,
and a
is the head of the sub-expression
a[b, c]
.
Head[ a[b, c][d, e] ] === a[b, c]
Head of Atoms
Atomic Expression, such as number, string, symbol, are also given a head.
Head of Numbers
Head[3] === Integer
Head[3.0] === Real
Head[3/4] === Rational
Head[3+ 4 I] === Complex
Head of symbol, string, special character
Head[ x ] === Symbol
Head[ Pi ] === Symbol
Head[ "abc" ] === String
Head[ \[Pi] ] === Symbol