Re: What's the error in this macro?

Liste des GroupesRevenir à cl scheme 
Sujet : Re: What's the error in this macro?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 21. Sep 2024, 14:29:23
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcmhni$1k4sf$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
KK wrote:

(defmacro sum (expression index initial condition)
;; Sum $expression$ for $index$ = $initial$ and successive integers,
;; as long as $condition$ holds.
  (let ((temp (gensym)))
    `(do ((,temp 0 (+ ,temp ,expression))
          (,index ,initial (1+ ,index)))
         ((not ,condition) ,temp))))
 
The main error with this macro is that it does something you could do
with the standard LOOP. I.e. instead of debugging this macro, you could
be working on the program where this macro is intended to be used:
 

 (loop for x from 1 while (< x 6) summing x)
 -> 15

Gauche Scheme

(use srfi-42) ;; sum-ec

(sum-ec (:range x 1 6) x)
  ===>
15

Date Sujet#  Auteur
21 Sep 24 * Re: What's the error in this macro?2B. Pym
24 Sep 24 `- Re: What's the error in this macro?1HenHanna

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal