Exercise · Volume 1 · 2.3-19
Exercise 2.3-19
not stated yet in Lean solution written
| Rating | 15 |
|---|---|
| Kind | K8, compute by machine: find a number or an object by a large computation from the written solution |
| Section | Section 2.3 of Volume 1 |
The task
Draw a List diagram for . Find and .
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
The second element of is a List with one element, and that element is itself. In a diagram draw an arrow back to .
Solution
Show the solution
has two elements: the atom , and the List . The List has one element, which is itself. So the diagram has a cycle.
L: [ a , * ]
|
v
[ * ]
|
+----> back to L
The second element of is . So . Then is the first element of , which is . So is the first element of , namely the atom .
Answer: and .
Check
A python3 list with a self reference, L = ['a', None]; L[1] = [L], gives L[1] equal to [L], L[1][0] is L true, and L[1][0][0] equal to 'a'.
Remarks
A List can contain itself, so it need not be a tree. This is the main difference between Lists and trees.
This solution is drafted, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.