Sidebar
Pascal Bourguignon wrote: (defun sum (list) (loop :for x :in list :sum x)) Gauche Scheme (define (sum lst) (fold + 0 lst)) (sum '(1 3 5 7 9)) ===> 25
(defun sum (list) (loop :for x :in list :sum x))
Of course, since LOOP is a higher level abstraction. You should compare with this iterative form: (defun sum (list) (do ((current list (cdr current)) (sum 0)) ((null current) sum) (setf sum (+ sum (car current)))))