Why don't people like lisp?
Luke Gorrie
luke at bluetail.com
Sun Oct 19 11:22:17 EDT 2003
Pascal Costanza <costanza at web.de> writes:
> Apparently, Paul Graham doesn't like CLOS nor the LOOP macro. Here is
> another verson in Common Lisp (and this is not a dream language ;):
>
> (defmethod mostn (fn (list (eql nil)))
> (declare (ignore fn list))
> (values nil nil))
>
> (defmethod mostn (fn list)
> (loop with result = (list (car list))
> with max = (funcall fn (car list))
> for object in (cdr list)
> for score = (funcall fn object)
> when (> score max) do (setq max score
> result (list object))
> when (= score max) do (push object result)
> finally return (values (nreverse result) max)))
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)))
-Luke
More information about the Python-list
mailing list