Sujet : Re: sequence iteration
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 23. Jun 2025, 02:49:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103abre$vmdi$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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