(define (make-queue)
(let ((front-ptr '())
(rear-ptr '()))
(define (insert-queue! item)
(let ((new-pair (cons item '())))
(cond ((null? front-ptr)
(set! front-ptr new-pair)
(set! rear-ptr new-pair))
(else
(set-cdr! rear-ptr new-pair)
(set! rear-ptr new-pair)))))
(define (delete-queue!)
(cond ((null? front-ptr)
(error "DELETE! called with an empty queue"))
(else
(set! front-ptr (cdr front-ptr)))))
(define (print-queue)
(display front-ptr))
(define (dispatch m)
(cond ((eq? m 'insert) insert-queue!)
((eq? m 'delete) (delete-queue!))
((eq? m 'print) (print-queue))
(else
(error "Error operator"))))
dispatch))
(define q1 (make-queue))
((q1 'insert) 'a)
(q1 'print)
((q1 'insert) 'b)
(q1 'print)
(q1 'delete)
(q1 'print)
(q1 'delete)
(q1 'print)