(load "queue.txt") ; 1 ]=> (define q1 (make-queue)) ; ; ;Value: q1 ; ; 1 ]=> (insert-queue! q1 'a) ; ; ;Value: ((a) a) ; ; 1 ]=> (insert-queue! q1 'b) ; ; ;Value: ((a b) b) ; ; 1 ]=> (delete-queue! q1) ; ; ;Value: ((b) b) ; ; 1 ]=> (delete-queue! q1) ; ; ;Value: (() b) ; The evaluator is printing the queue like a pair with a list as the first ; element and an atom as the second, because that is the internal ; representation hidden behind the queue abstraction. The reason the last ; queue element appears twice in the output is because the rear pointer points ; into the list the front pointer points to. The interpreter will print the ; list of elements and then follow the rear pointer which points to an already ; printed element. ; Because the interpreter does not understand the meaning of the queue ; internals, we must program our own print function which takes into account ; the meaning of the queue internals. (define (print-queue queue) (display (front-ptr queue)))