Most of the data you handle while programming in the Wolfram language will usually be held in lists or easily transformed into lists so it is worthwhile that we dive deeper into lists.

Today is a continuation of lists that we saw previously. Let’s dive in

Today is a continuation of lists that we saw previously. Let’s dive in

You can apply operations directly to elements of a list

Range[5]

In[]:=

{1,2,3,4,5}

Out[]=

Let’s multiply all the elements by 5

Range[5]*5

In[]:=

{5,10,15,20,25}

Out[]=

Let’s add the previous result to the one before it

(Range[5]*5)+Range[5](*Weuseparenthesistoprioritizeoperations..andthisisacomment*)

{6,12,18,24,30}

Out[]=

We have seen the Range function now lets use its powerful counter Table

Creating a Table of even numbers up to 10

Table[x,{x,2,10,2}]

In[]:=

{2,4,6,8,10}

Out[]=

What about squares

Tablex,{x,10}

2

In[]:=

{1,4,9,16,25,36,49,64,81,100}

Out[]=

It’s sometimes useful to repeat values

Table[x,5]

In[]:=

{x,x,x,x,x}

Out[]=

Let’s extract the squares of 5,6 and 7 using their indices

Tablex,{x,10}[[5;;7]]

2

In[]:=

{25,36,49}

Out[]=

## Exercises

Exercises

1. Using Range or Table generate a list of cubes

2. Use the Sqrt[ ] function to generate a list of the first 10 square roots i.e. from 1 to 10

3. Filter this list using indexing to get the last half of the of the list of square roots.

2. Use the Sqrt[ ] function to generate a list of the first 10 square roots i.e. from 1 to 10

3. Filter this list using indexing to get the last half of the of the list of square roots.

### Tip

Tip

Always feel free to use the documentation in your Mathematica installation or use the web version at: https://reference.wolfram.com/language/