| Deutsch English Français Italiano |
|
<vcmhni$1k4sf$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "B. Pym" <Nobody447095@here-nor-there.org> Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: What's the error in this macro? Date: Sat, 21 Sep 2024 13:29:23 -0000 (UTC) Organization: A noiseless patient Spider Lines: 25 Message-ID: <vcmhni$1k4sf$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Sat, 21 Sep 2024 15:29:23 +0200 (CEST) Injection-Info: dont-email.me; posting-host="78f553967f83f2d994405934525231d2"; logging-data="1708943"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HSlHFfEUROe1F2jawWm5c" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:hkff1fGp3I1sH2Y1wrRBnlgVM+E= Bytes: 1580 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