Re: Debugger features

Liste des GroupesRevenir à cl scheme 
Sujet : Re: Debugger features
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 01. Jul 2025, 05:51:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103vphc$2lkdn$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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)

Date Sujet#  Auteur
1 Jul 25 o Re: Debugger features1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal