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):

Use Max to get the largest element of v:

Set up a 4×3 matrix of random integers between 0 and 10:

Use Map to apply Max to each element of m at the top level:

    

You can add two lists of the same length element by element:

Add the scalar c to each element of a list:

Multiply each element in the list by the scalar k:

    

Set up a list of 5 integers:

Prepend the element x at the beginning of the list v:

Append x at the end of v:

Insert the element x at position 3 of the list v:

Delete the element at position 3 in v:

Replace the element at position 3 in v with a new element x:

Interleave x between the entries of v:

  • Adding, Removing, and Modifying List Elements
  • Operations on Scalars, Vectors, and Matrices
  • Manipulating Lists by Their Indices
  • How to: Work with Lists
  • List  Prepend  Append  Map  Apply  Insert  Delete  ReplacePart  Riffle

  • List Manipulation
  • Elements of Lists
  • "How to" Topics