The head of an expression
In the Wolfram language / Mathematica, "everything is an expression," to quote a tutorial. I think that every expression has a head. According to the tutorial:
The object $f$ in an expression $f[x, y, ...]$ is known as the head of the expression. You can extract it using
Head[expr].
Indeed, I can use Head to extract the head of several example expressions:
{myNull, mySymbol, myInteger, myReal, myString, myList, myFunction, myCompositionOfFunctions1, myCompositionOfFunctions2, myRule1, myRule2, myAssociation1, myAssociation2, myExpression1, myExpression2, myMultiplicationExpression1, myMultiplicationExpression2, myEquation1, myEquation2} = {Null, abc, 123, 123.0, "ABC", {1, 2.0, "A"}, f[x, y], f[g[h[x, y]]], Composition[f, g, h][x, y], Rule[a, b], a -> b, <|firstName -> "John", lastName -> "Doe"|>, Association[firstName -> "Jane", lastName -> "Doe"], x + y + z, Plus[x, y, z], a / b, Times[a, Power[b, -1]], a x^2 + b x + c == 0, Equal[Plus[Times[a, Power[x, 2]], Times[b, x], c], 0]}; Head /@ {myNull, mySymbol, myInteger, myReal, myString, myList, myFunction, myCompositionOfFunctions1, myCompositionOfFunctions2, myRule1, myRule2, myAssociation1, myAssociation2, myExpression1, myExpression2, myMultiplicationExpression1, myMultiplicationExpression2, myEquation1, myEquation2} which gives this output:
(* {Symbol, Symbol, Integer, Real, String, List, f, f, f, Rule, Rule, Association, Association, Plus, Plus, Times, Times, Equal, Equal} *) Visualizing an expression's structure: example 1
We can visualize the structure of an expression in Wolfram language / Mathematica using TreeForm. For example, consider f[g[a, h[x, y], b]]:
TreeForm[f[g[a, h[x, y], b]]] which gives this graphical output:
(The stick figure is my artistry.) The head of f[g[a, h[x, y], b]] is indeed f:
Head[f[g[a, h[x, y], b]]] (* f *) Visualizing an expression's structure: example 2
As another example, the head of {g["a", h[x, y], "b"]} is List:
Head[{g["a", h[x, y], "b"]}] (* List *) And the tree representation of {g["a", h[x, y], "b"]} looks like this:
TreeForm[{g["a", h[x, y], "b"]}] (Again, the stick figure is my artistic handiwork. Also, interestingly, the heads of "a" and "b" are not shown explicitly in the tree representation. Note that Head["a"] and Head["b"] each give String.)
Question
- Is a head of an expression called a head because in the tree representation of the expression, the expression's head is at the top -- like how my own head is at the top of my body?
- Or is "head" a term from mathematics or computer science, or short for "header"?


Function? $\endgroup$