• Re: applying macros

    From B. Pym@21:1/5 to Rainer Joswig on Thu Sep 19 07:32:45 2024
    XPost: comp.lang.lisp

    Rainer Joswig wrote:

    (defun average-function (list)
    (assert list (list)
    "List should not be empty.")
    (loop for i from 0
    for item in list
    sum item into result
    finally (return (/ result i))))

    It's shorter in Gauche Scheme.

    (define (average-function lst)
    (let1 n 0
    (/ (fold (lambda (x sum) (inc! n) (+ x sum)) 0 lst)
    n)))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)