title: Lisp list number of element
body: <p>I'm preparing myself for my upcoming exam in LISP and I've come across a problem I can't solve, so I was hoping someone more experienced might help me out.Im trying to make a recursive lisp program that returns the position of an element n from a list but i cant use nth.I need to verify if n is in the list between 0 and length of the list -1 if the element is not in the list a error message should appear.
  Something like this:<code>(my-list '(1 2 3) 4) =&gt;"error the list has only 3 elements"</code>
  Can someone help me with this problem Im still a novice when it comes to LISP</p>
  
  <p>My code so far:</p>
  
  <pre><code>(defun no-nth (n list)
    (declare (type (integer 0) n) (type list))
    (if (or (zerop n) (null list))
      (cons (car list) (no-nth (1- n) (cdr list)))))
  </code></pre>