CompuServe Messages

LISP ???

    22-Apr-88 01:12:17
Sb: #22090-LISP ???
Fm: Duff Kurland [Adesk] 72407,2764
To: David Maki 76077,2375
David – Here's another method involving a recusrive "mymin" function: (defun mymin (a) (cond ((> (length a) 2) (mymin (cons (min (car a) (cadr a)) (cddr a)))) ((= (length a) 2) (min (car a) (cadr a))) (T "Argument must be list of 2 or more numbers") ) ) Assuming you've done something like (setq s1 (list 1.2 3.4 5 6.7)), you'd use this thing by entering (mymin s1). "mymin" compares the first two numbers in the list, and calls itself again with the smaller of these at the head of the remaining list. This continues until there are only two items left in the list. Brad's method is simpler, but I didn't see his until I was about to send mine. Oh well, it was a nice exercise. .