rear-deque.scm (644B)
1 (define-library (sicp solutions chapter-3 exercise-23-stuff rear-deque) 2 (import (scheme base)) 3 4 (import (sicp solutions chapter-3 exercise-23-stuff empty-deque)) 5 (import (sicp solutions chapter-3 exercise-23-stuff rear-ptr)) 6 (import (prefix (sicp solutions chapter-3 exercise-23-stuff doubly-linked-list) dll:)) 7 8 9 (export rear-deque) 10 11 (begin 12 (define (rear-deque deque) 13 "Returns the rearmost item if the deque is not empty. 14 If deque is empty raises an error." 15 (cond 16 ((empty-deque? deque) 17 (error "REAR-DEQUE called with an empty deque" deque)) 18 (else 19 (dll:link-item (rear-ptr deque)))))))