Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: "B. Pym" Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: Debugger features Date: Tue, 1 Jul 2025 04:51:59 -0000 (UTC) Organization: A noiseless patient Spider Lines: 72 Message-ID: <103vphc$2lkdn$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Tue, 01 Jul 2025 06:51:59 +0200 (CEST) Injection-Info: dont-email.me; posting-host="80eb908aba73a614f11866a99be294b3"; logging-data="2806199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FqdYGh61pNS6zzOLoINbn" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:TR2czT+K1d/rZK8hW7Mgqj4l2EA= Alan Crowe wrote: > Macros let you abstract control structures. For example, > with a list (a b c d) you might want to compute > (f a b),(f b c),(f c d) > Another popular pattern is > (f a b),(f b c),(f c d)(f d a) > It is natural to define macros > > * (dolinks (x y '(a b c d ) 'done)(print (cons x y))) > (A . B) > (B . C) > (C . D) > DONE > > * (docycle (x y '(a b c d ) 'done)(print (cons x y))) > (A . B) > (B . C) > (C . D) > (D . A) > DONE > > The alternative is to come up with cliches and use them > repeatedly in ones code. I've not done too well at coming up > with cliches taught enough to bear repeated typing; best so > far: > > * (loop with list = '(a b c d) > for x = (car list) then y > and y in (cdr list) > do (print (cons x y))) > (A . B) > (B . C) > (C . D) > NIL Gauche Scheme (let1 List '(a b c d) (for-each (lambda(x y) (print (cons x y))) List (cdr List))) (a . b) (b . c) (c . d) > > * (loop for (x . rest) on '(a b c d) > for y = (car rest) > when (null rest) do (setf y 'a) > do (print (cons x y))) > (A . B) > (B . C) > (C . D) > (D . A) > NIL (use srfi-1) ;; circular-list (let1 List '(a b c d) (for-each (lambda(x y) (print (cons x y))) List (cdr (apply circular-list List)))) (a . b) (b . c) (c . d) (d . a)