Skip to content

Commit 455c87e

Browse files
committed
Added comments, cleanup 3.23
1 parent 217c539 commit 455c87e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

3.0/3.22.scm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
; Exercise 3.22. Instead of representing a queue as a pair of pointers, we can build a queue as a procedure with local state. The local state will consist of pointers to the beginning and the end of an ordinary list. Thus, the make-queue procedure will have the form
2+
3+
; (define (make-queue)
4+
; (let ((front-ptr ...)
5+
; (rear-ptr ...))
6+
; <definitions of internal procedures>
7+
; (define (dispatch m) ...)
8+
; dispatch))
9+
10+
; Complete the definition of make-queue and provide implementations of the queue operations using this representation.
11+
112
(define (make-queue)
213
(let ((front-ptr '())
314
(rear-ptr '()))

3.0/3.23.scm

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
deque))))
3838
(define (front-delete-deque! deque)
3939
(cond ((empty-deque? deque)
40-
(error "empty queue" '()))
40+
(error "empty queue" '()))n
4141
(else
4242
(set-front-ptr! deque (cdr (front-ptr deque))))))
4343
(define (rear-delete-deque! deque)
@@ -47,9 +47,7 @@
4747
(let ((prev-pair (get-ptr (car (rear-ptr deque)))))
4848
(set-rear-ptr! deque prev-pair)))))
4949

50-
51-
52-
;;;; accessor method;;;
50+
;;;; item accessor method ;;;
5351
(define (get-value item)
5452
((item 'get-item)))
5553
(define (get-ptr item)
@@ -63,10 +61,10 @@
6361
((it 'set-item!) val)
6462
it))
6563

66-
67-
68-
;;; abstraction of the data stored
69-
;;; in the list, the data has a value, and a rear pointer.
64+
;;; Item represents a cell entry
65+
;;; in the linked list, the rear ptr of the cell/item
66+
;;; represents the previous entry, it acts similar
67+
;;; to a doubly linked list
7068
(define (item)
7169
(define null '())
7270
(define value '())

0 commit comments

Comments
 (0)