WolframLang: List

By Xah Lee. Date: . Last updated: .

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.

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

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

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} } ]
WolframLang TreeForm 2022-07-06 hdYYw
WolframLang TreeForm 2022-07-06

WolframLang List