Exercise 3.32. The procedures to be run during each time segment of the agenda are kept in a queue. Thus, the procedures for each segment are called in the order in which they were added to the agenda (first in, first out). Explain why this order must be used. In particular, trace the behavior of an and-gate whose inputs change from 0,1 to 1,0 in the same segment and say how the behavior would differ if we stored a segment's procedures in an ordinary list, adding and removing procedures only at the front (last in, first out). ———————————————————————————————————————————————————————————————————————— The and-gate definition given in the text: (define (and-gate a1 a2 output) (define (and-action-procedure) (let ((new-value (logical-and (get-signal a1) (get-signal a2)))) (after-delay and-gate-delay (lambda () (set-signal! output new-value))))) (add-action! a1 and-action-procedure) (add-action! a2 and-action-procedure) 'ok) In a change from 0,1 to 1,0, both the a1 and a2 input values are change and so the and-action-procedure will be called twice. If the a1 signal is changed first, then in the first call to after-delay the values will be 1,1, since the a1 signal has changed and the a2 signal has not yet changed, and so the output signal will be 1. If the a2 signal changes next, the correct output 0 will be added to the agenda after the incorrect output. Since spurious transient outputs may be added to the agenda before correct ones, it is important that the last item added to the agenda at a given time segment is the last one called.