2.17|

$ cd ~

SICP Exercise 2.17

(define (last-pair items)
  (let ((l (length items)))
    (list-ref items (- l 1))))

(define (length items)
  (if (null? items)
      0
      (+ 1 (length (cdr items)))))

(define (list-ref items n)
  (if (= n 0)
      (car items)
      (list-ref (cdr items) (- n 1))))

There exists a better solution without using either list-ref or length:

(define (better-last-pair items)
  (let ((rest (cdr items)))
    (if (null? rest)
        items
        (last-pair rest))))