Simple List Operations

left top right

(define (list? l)
  (or (null? l)
      (and (pair? l) (list? (cdr l)))))

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

(define (list-ref l n)
  (cond ((null? l) (error "..."))
        ((= 0 n) (car l))
        (else (list-ref (cdr l) (- n 1)))))

Jim Miller W3C