Why don't people like lisp?

Paul Rubin http
Sun Oct 19 13:37:50 EDT 2003


Wade Humeniuk <whumeniu at nospamtelus.net> writes:
> (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)))

This is untested but looks simpler than the lisp example:

    def mostn (fn, lst):
      max = None
      for a in lst:
         score = fn(lst)
         if max is None or score > max:
            max = score
            ret = [a]
         elif score == max:
            ret.append(a)
      return ret




More information about the Python-list mailing list