Devise a correct version of the count-pairs procedure of exercise that returns the number of distinct pairs in any structure. Write a procedure that examines a list and determines whether it contains a cycle, that is, whether a program that tried to find the end of the list by taking successive cdr s would go into an infinite loop. Redo exercise using an algorithm that takes only a constant amount of space. The same observation is true for mutable data. We can implement mutable data objects as procedures using assignment and local state.
Assignment is all that is needed, theoretically, to account for the behavior of mutable data.