;;; $Id: nth-element.scm,v 1.1 2004/01/29 04:53:50 leavens Exp $ ;;; AUTHOR: Dalei Li and Gary T. Leavens (deftype nth-element (forall (t) (-> ((list-of t) number) t))) (define nth-element (lambda (lst n) ;; ENSURES: Result is the nth, zero-based, element of lst (if (null? lst) (eopl:error 'nth-element "List too short by ~s elements" (+ n 1)) (if (zero? n) (car lst) (nth-element (cdr lst) (- n 1))))))