3 ms·
Note that to make it correct Common Lisp, you'd write it like that: (defun avg-popularity (list) (loop for item in list for pop = (popular
by TeMPOraL 7y ago
Note that to make it correct Common Lisp, you'd write it like that:
(defun avg-popularity (list)
(loop
for item in list
for pop = (popularity item)
when (plusp pop)
sum pop into s
and
count t into c
finally (return (/ s c))))
Two changes: 1) making `pop' be a thing, and 2) `when' clause of loop only applies to the next clause by default (here, `sum pop into s'), you need to include `and' to chain it with the next one so that both are guarded by `when' condition.