Sujet : Re: what's the best way to do this?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.schemeDate : 09. Jul 2025, 06:29:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <104kuo9$30bp$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Pascal Bourguignon wrote:
(format t "~{~S~^:~}" list)
I suspect this is the best LOOP that can be constructed:
>
(loop for item in list
for first = t then nil
if first do (format t "~S" item)
else do (format t ":~S" item))
If you don't want to use the simple format, you should rather avoid it
in the loop.
(when list
(loop initially (princ (car list))
for item in (cdr list)
do (princ ":") (princ item) ))
Gauche Scheme
(define seq '(a b c d))
(when (pair? seq)
(display (pop! seq))
(for-each (cut format #t ":~a" <>) seq))
===>
a:b:c:d