| Deutsch English Français Italiano |
|
<v79cj0$2115e$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups: comp.lang.lisp
Subject: Re: can format ~{...~} enumerate list items?
Date: Wed, 17 Jul 2024 21:20:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v79cj0$2115e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 17 Jul 2024 23:20:33 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b954c532275ead01d490994b1aaa25a5";
logging-data="2131118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/I75z5kgGwq/E4finJTkLl"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:zVm7Tz/w6UEv61aNIbN9BCFhEc4=
Bytes: 1676
Pascal J. Bourguignon wrote:
> (defun counting (list &optional (from 1))
> (mapcar (let ((i (1- from)))
> (lambda (x)
> (if (consp x)
> (cons (incf i) x)
> (list (incf i) x))))
> list))
>
> (let ((arguments '(aa bb cc)))
> (format t "~:{~A. ~A~%~}" (counting arguments)))
>
> 1. AA
> 2. BB
> 3. CC
Gauche Scheme
(define (print-counted the-list :optional (from 0))
(for-each
(lambda (i x) (print i ". " x))
(lrange from)
the-list))
gosh> (print-counted '(a bb ccc))
0. a
1. bb
2. ccc
gosh> (print-counted '(a bb ccc) 233)
233. a
234. bb
235. ccc
Shorter:
(define (print-counted the-list :optional (from 0))
(for-each
(cut print <> ". " <>)
(lrange from)
the-list))