Sidebar
"B. Pym" <No_spamming@noWhere_7073.org> writes: < > (defun avg (args) < > (loop for x in args < > for l upfrom 1 < > summing x into tot < > finally (return (/ tot l))))
Gauche Scheme (use gauche.collection) ;; fold2 (define (add&count n sum cnt) (values (+ sum n) (+ cnt 1))) (define (avg nums) (apply / (values->list (fold2 add&count 0 0 nums)))) (avg '(20 30 40 50 60 70 80)) ===> 50
(loop for x in '(1 2 3 4 5) summing x into max counting x into cnt finally (pprint (/ max cnt))) [[callf / sum len] '(1 2 3 4 5)]