First Look at Lists

Lists are a basic way to collect things together in the Wolfram Language. {1,2,3} is a list of numbers. On their own, lists don’t do anything; they’re just a way to store things. So if you give a list as input, it’ll just come back unchanged:

{1,2,3,4,a,b,c}

ListPlot is a function that makes a plot of a list of numbers.

ListPlot[{1,1,2,2,3,4,4}]

ListPlot[{10,9,8,7,3,2,1}]

Range is a function that makes a list of numbers.

Range[10]

ListPlot[Range[20]]

Reverse reverses the elements in a list.

Reverse[{1,2,3,4}]

Reverse[Range[10]]

ListPlot[Reverse[Range[10]]]

Join joins lists together, making a single list as the result.

Join[{1,2,3},{4,5},{6,7}]

Join[{1,2,3},{1,2,3,4,5}]

Join[Range[3],Range[5]]

ListPlot[Join[Range[20],Range[20],Range[30]]]

ListPlot[Join[Range[20],Reverse[Range[20]],Range[30]]]

Use Range to create the list {1,2,3,4}. »

Make a list of numbers up to 100. »

Use Range and Reverse to create {4,3,2,1}. »

Make a list of numbers from 1 to 50 in reverse order. »

Use Range, Reverse and Join to create {1,2,3,4,4,3,2,1}. »

Plot a list that counts up from 1 to 100, then down to 1. »

Use Range and RandomInteger to make a list with a random length up to 10. »

Find a simpler form for Reverse[Reverse[Range[10]]]. »

Find a simpler form for Join[{1,2},Join[{3,4},{5}]]. »

Find a simpler form for Join[Range[10],Join[Range[10],Range[5]]]. »

Find a simpler form for Reverse[Join[Range[20],Reverse[Range[20]]]]. »

Compute the reverse of the reverse of {1,2,3,4}. »

Use Range, Reverse and Join to create the list {1,2,3,4,5,4,3,2,1}. »

Use Range, Reverse and Join to create {3,2,1,4,3,2,1,5,4,3,2,1}. »

Plot the list of numbers {10,11,12,13,14}. »

Find a simpler form for Join[Join[Range[10],Reverse[Range[10]]],Range[10]]. »

How does one read {1,2,3} out loud?

Usually “list 1 2 3”. “{” and “}” are called “braces” or “curly brackets”. “{” is “open brace” and “}” is “close brace”.

Is a list a function?

Yes. {1,2,3} is List[1,2,3]. But unlike, say, Plus, the function List doesn’t actually compute anything; it just comes back unchanged.

What is ListPlot plotting?

The values of successive list elements. The x value of each point gives the position in the list; the y value gives the value of that element.

How long can lists be?

As long as you want, until your computer runs out of memory.

Tech Notes