In this example, we prove that the list

[3, [2, [1, []]]]

Contains 1 at index 2.

We track the "current index" which is initially 0. Starting with the first element, if the element is not the value we are looking for, then we move on to the next element by popping the list and incrementing the current index by 1.

After a few iterations, the list becomes

[1, []]

and the current index is 2. At this point, the first element is the value we are looking for, so we stop.

Quiz (1 point)

Prove that:
index of value 1 in [ 3, [ 2, [ 1, [ ] ] ] ] = 2

The following properties may be helpful:

Please write your proof in the table below. Each row should contain one claim. The last claim is the statement that you are trying to prove.

Step Claim Reason (optional) Error Message (if any)
1
2
3
4
5
6
7
8
9
10

Become a subscriber to save your progress, see the correct answer, and more!