Re: what's the best way to do this?

Liste des GroupesRevenir à cl scheme 
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.scheme
Date : 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

Date Sujet#  Auteur
9 Jul06:29 o Re: what's the best way to do this?1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal