learning-sicp

My embarrassing half assed SICP run.
Log | Files | Refs

rear-deque.scm (552B)


      1 (define-library (sicp solutions 3_23 rear-deque)
      2   (import (scheme base))
      3 
      4   (import (sicp solutions 3_23 empty-deque))
      5   (import (sicp solutions 3_23 rear-ptr))
      6   (import (prefix (sicp solutions 3_23 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)))))))