By defining a list of values, you can quickly plot a series of points, lines, or curves, or calculate statistical values such as mean, median, or standard deviation. Get started with the video on the right, then dive deeper with the resources and challenges below.

## Getting Started with Lists

Create a list of values in between square brackets and separate elements with commas, such as \([1,3,4]\).

To generate a list of evenly spaced numbers, use an ellipsis. For example, \([1...10]\) represents the list of integers between \(1\) and \(10\) and \([1,3...11]\) represents the list of odd integers between \(1\) and \(11\).

To display all of the elements of a list, assign it to a variable, such as \(L=[1,3…11]\). Then, use \(L\) as the column header in a table. To insert a table, use the “add item” button at the top of the expression list, or just type ‘table’ into a blank expression line.

You can use lists in any expression where you would use a single number, including the definition of a variable. This allows you to graph multiple lines or curves simultaneously.

If \(L\) is a list, you can refer to individual elements or subsets of elements by choosing the index of that element:

- Access the first element of \(L\) with \(L[1]\)
- Create a new list of the first, third, and fifth elements of \(L\) with \(L[1,3,5]\)
- \(L[1…5]\) accesses the first \(5\) elements
- Generate a list of elements of \(L\) from the third to the last with \(L[3…]\)
- Pull out the positive elements of \(L\) with \(L[L \gt 0]\)
- If \(M\) is another list, produce a list of elements from \(L\) at the indices specified by \(M\) with \(L[M]\)

See examples of each of these here.

## Lists in Geometry

In Desmos Geometry, use lists to define parameters in transformations, create concentric circles, or make “string” art with gliders. Read more about gliders in our Sliders and Movable Points article.

## Lists in 3D

In Desmos 3D, you can use lists to plot multiple points and graph multiple curves or surfaces. For instance, if you define a list \(L=[-4…4]\), then the expression \((L,L,L)\) will graph \(9\) points arranged in a diagonal line. Similarly, the expression \((L\sin(t), L\cos(t), L)\) will graph \(9\) circles, each with a radius and position on the \(z\)-axis defined by the values of \(L\).

## List Comprehension

You can create new lists based on existing lists using a *list comprehension*, which looks like this: \(\left(x,y\right)\operatorname{for}x=\left[1...10\right],y=\left[1...10\right]\). This would create a list of the 100 points with integer coordinates \(1\le x \le 10\), \(1\le y \le 10\) and form a 10x10 grid of points.

A list comprehension consists of a "body" expression--in this case `(x,y)`--and one or more "input list" variables. The resulting list is created by evaluating the body expression for each combination of values from the input lists.

Here are some more examples of list comprehensions and the lists they produce:

Comprehension |
Result |
---|---|

\(2i\operatorname{for}i=\left[1,2,3\right]\) | \( [2, 4, 6]\) |

\(1\operatorname{for}i=\left[1...1000\right]\) | \([1, 1, 1, ...\)\((1000\) times)\(]\) |

\(\operatorname{mean}\left(L.\operatorname{random}\left(10\right)\right)\operatorname{for}i=\left[1...100\right]\) | A list of \(100\) mean values, each calculated from \(10\) randomly selected values of list \(L\). |

## Learn More

- Lists Walk Through
- Explore Lists Example Graph
- Functions
- Generalizing "for" Lists and Intervals
- Tables

Please write in with any questions or feedback to support@desmos.com.