• Re: sequence iteration

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Mon Jun 23 01:49:35 2025
    From Newsgroup: comp.lang.lisp

    Don Geddis wrote:

    Is there any generic iteration contruct for sequences? Ideally it
    would work just like DOLIST.
    > (do-sequence (e "ab c")
    (print e))
    #\a
    #\b
    #\Space
    #\c
    nil

    Well, I don't know if you consider the LOOP macro to be Common Lisp, but
    the following works in Allegro CL 4.2:

    USER(20): (loop for x across "ab c" do (print x))

    #\a
    #\b
    #\space
    #\c
    NIL

    CLtL2 says that the "across" keyword works for iteration over arrays (vectors),
    so it looks to be not quite as generic as over sequences. But it's close.

    Gauche Scheme

    (use gauche.collection)

    (for-each print '(a b c))
    a
    b
    c

    (for-each print #(a b c))
    a
    b
    c

    (for-each print "abc")
    a
    b
    c

    --- Synchronet 3.21d-Linux NewsLink 1.2