WolframLang: List
List: the Foundational Structure of WolframLang Expression
List is the most fundamental data structure of WolframLang. Every expression, is a list. Entire WolframLang, is made up of lists.
List[expr1, expr2, etc]
-
🔸 SHORT SYNTAX:
{expr1, expr2, etc}
return a list.
(* a list *) {3, 4, 5} (* FullForm syntax *) List[ 3, 4, 5 ]
List can nest in any way.
{3, 4, {1,2}, 5}
Length
Length[expr]
-
return the length of expression.
Length[ {3, 4, 5} ] === 3
Length[ f[3, 4, 5] ] === 3
List Represents Array, Vector, Matrix, Tree
Vector is List
A vector (linear algebra) is reprented by a list. e.g. {a,b,c}
is a 3-dimensional vector.
Matrix is List
A matrix (linear algebra) is reprented by nested list. e.g. a 2 by 3 matrix:
{
{a,b,c},
{1,2,3}
}
where
{a,b,c}
is first row.{1,2,3}
is second row.
Tree Data Structure is List
A tree data structure is a nested list.
e.g. { { {a, b }, m }, {1, 2 } }
.
TreeForm[ { {{a,b},m}, {1,2} } ]