Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "B. Pym" Newsgroups: comp.lang.lisp Subject: Re: can format ~{...~} enumerate list items? Date: Thu, 15 Aug 2024 03:11:50 -0000 (UTC) Organization: A noiseless patient Spider Lines: 58 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Thu, 15 Aug 2024 05:11:50 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7e5ecf5f7253603983f636ec904f7241"; logging-data="871252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OQb5yGsLrEqIBJh4+Wz89" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:/UmL49iD3ifAyh7DCuEQ3ClGbDQ= Bytes: 2006 B. Pym wrote: > 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)) newLISP (define (print-counted the-list (from 0)) (dolist (x the-list) (println (+ from $idx) ". " x))) > (print-counted '(aa bb cc) 700) 700. aa 701. bb 702. cc