Here is the skeleton for a queue that uses message passing.
Note that you do not pass a queue as an input to a queue object. It is already a queue!
Peek is already written. Blanks do not imply that only one line of code is needed. They do imply that some amount of code is needed.
(define (make-queue) (let ((front-ptr '()) (rear-ptr '())) ; empty-queue? is written to align with the way front-ptr ; and rear-ptr were given, above (define (empty-queue?) ________) ; peek returns the datum at the front of the queue ; peek returns #f if the queue is empty (define (peek) (cond ((empty-queue?) (error "Empty queue. :-(")) (else (car front-ptr)))) ; insert-queue! plays out differently depending on whether the queue ; is currently empty or not (define (insert-queue! datum) (let ((new-node (cons datum ()))) ________)) ; delete-queue! has three possibilties: ; * empty queue ; * one element in queue ; * more than one element in queue (define (delete-queue!) (cond ((empty-queue?) (error "Empty queue. :-(")) (else ; store the datum at the head of the queue (let ((return-value (peek))) ; update the front pointer ________ ; If there was only one thing in the queue, then the ; rear-ptr will need to be set to nil (if (null? front-ptr) ________) ; Now return the element of the queue (or #f) ________)))) (define (dispatch message) (cond ((eq? message 'insert-queue!) insert-queue!) ((eq? message 'delete-queue!) delete-queue!) ((eq? message 'peek) peek) ((eq? message 'empty?) empty-queue?))) ________))