How to | Perform Operations on Lists
Lists are central constructs in the Wolfram Language that are used to represent collections, arrays, sets, and sequences of all kinds. Well over a thousand built-in functions throughout the Wolfram Language operate directly on lists, making them a powerful vehicle for interoperability.
Set up a list of 5 random integers between 0 and 10 (stored as v):
v = RandomInteger[10, {5}]Use Max to get the largest element of v:
Max[v]Set up a 4×3 matrix of random integers between 0 and 10:
m = RandomInteger[10, {4, 3}]Use Map to apply Max to each element of m at the top level:
Map[Max, m, 2]v = Range[5]Prepend the element x at the beginning of the list v:
Prepend[v, x]Append[v, x]Insert the element x at position 3 of the list v:
Insert[v, x, 3]Delete the element at position 3 in v:
Delete[v, 3]Replace the element at position 3 in v with a new element x:
ReplacePart[v, 3 -> x]Interleave x between the entries of v:
Riffle[v, x]