• Re: Debugger features

    From B. Pym@21:1/5 to Alan Crowe on Tue Jul 1 04:51:59 2025
    XPost: comp.lang.scheme

    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)

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