Making Lists of Objects

In doing calculations, it is often convenient to collect together several objects, and treat them as a single entity. Lists give you a way to make collections of objects in the Wolfram Language. As you will see later, lists are very important and general structures in the Wolfram Language.

A list such as {3,5,1} is a collection of three objects. But in many ways, you can treat the whole list as a single object. You can, for example, do arithmetic on the whole list at once, or assign the whole list to be the value of a variable.

Here is a list of three numbers:

{3,5,1}

This squares each number in the list, and adds 1 to it:

{3,5,1}^2+1

This takes differences between corresponding elements in the two lists. The lists must be the same length:

{6,7,8}-{3.5,4,2.5}

The value of % is the whole list:

%

You can apply any of the mathematical functions in "Some Mathematical Functions" to whole lists:

Exp[%]//N

Just as you can set variables to be numbers, so also you can set them to be lists.

This assigns v to be a list:

v={2,4,3.1}

Wherever v appears, it is replaced by the list:

v/(v-1)