Why don't people like lisp?
Wade Humeniuk
whumeniu at nospamtelus.net
Sun Oct 19 13:29:38 EDT 2003
Luke Gorrie wrote:
> C'mon guys, live a little,
>
> (defun mostn (fn list)
> (let ((max (apply #'max (mapcar fn list))))
> (values (remove max list :test-not #'= :key fn) max)))
Yes, live a little, get messy. Why is there this insistence that
everything be neat and tidy? (in your dreams) In reality it never is,
that's the beauty of it.
(defun mostn (fn lst)
(let ((mostn-elems nil) (max nil))
(tagbody
find-mostn
(unless (null lst)
(let ((score (funcall fn (car lst))))
(cond
((or (null max) (> score max))
(setf max score mostn-elems (list (car lst))))
((= score max)
(push (car lst) mostn-elems)))
(setf lst (cdr lst))
(go find-mostn))))
(values (nreverse mostn-elems) max)))
Wade
More information about the Python-list
mailing list