Here's a basic looping question and what I thought was going to be a trivial problem. I want to find the smallest number in a list. The function min does not take a list, so I tried loop through it:

- Code: Select all
`(defun select (a)`

(let ((x 0))

(loop for i from 1 to (length a) do

(if (< i x)

(print (setf x i))))))

Could someone please point me in the right direction? This is definitely not returning what I want it to. Is there a simple way to find the smallest element in a list? If not, how might I alter my program to get the expected results?

This is what I am getting:

CG-USER(42): (SELECT '(1 2 3))

NIL

Thanks in advance!