title: Finding the smallest number in a list in Lisp using only a list in the constructor?
body: <p>My professor gave us this stumper on the midterm, and unless I'm not looking at it right, it's a pretty tough question that seems simple.</p>
  
  <blockquote>
    <ol start="7">
    <li>Write a lisp function f that finds the minimum value of a list. Assume that the list contains numbers only. For example (f '(3 2 5 4 9
    5)) returns 2.</li>
    </ol>
  </blockquote>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>(defun f (L)
   (cond ((null (cdr L))(car L))    ; &lt;-- I think my break case is wrong, too.
         ((&lt; (car L) (car (cdr L))) (rotatef((car L) (car(cdr L)))))
   (f(cdr L))
   )
  )
  </code></pre>
  
  <p>The compiler is telling me that my use of rotatef is bad. </p>
  
  <p>My logic is to continuously exchange the smallest element with <code>car(cdr L)</code>, and always have the <code>car(L)</code> as the smallest element. Then recursively call the <code>cdr</code> until there's only  that's the only way I could think to do it. Weird thing though is that he never mentioned <code>rotatef</code> in our notes, so I'm thinking I did something poorly. </p>
  
  <p>Oh great Lisp gods, can you help me? You're my only hope.</p>