Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #155: Dumb terminal


comp / comp.lang.lisp / Re: can format ~{...~} enumerate list items?

SubjectAuthor
* Re: can format ~{...~} enumerate list items?B. Pym
+- Re: can format ~{...~} enumerate list items?Kaz Kylheku
`- Re: can format ~{...~} enumerate list items?B. Pym

1
Subject: Re: can format ~{...~} enumerate list items?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 17 Jul 2024 21:20 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
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=
View all headers

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))

Subject: Re: can format ~{...~} enumerate list items?
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Thu, 18 Jul 2024 00:38 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: can format ~{...~} enumerate list items?
Date: Thu, 18 Jul 2024 00:38:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20240717173635.627@kylheku.com>
References: <v79cj0$2115e$1@dont-email.me>
Injection-Date: Thu, 18 Jul 2024 02:38:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1b5d4896b8b1840ce11109417f7214c5";
logging-data="2196254"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18W7mzAlOn2vvY5VIyQLj8zw/v1JQ0/LWY="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:enOVo/viSA2eY51vzWW3GXukD6o=
View all headers

On 2024-07-17, B. Pym <Nobody447095@here-nor-there.org> wrote:
> 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))

This is the TXR Lisp interactive listener of TXR 294.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
TXR was taped live before a studio audience. The laughter is genuine.
1> (mapdo (op put-line `@1. @2`) 1 '(a bb ccc))
1. a
2. bb
3. ccc

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: can format ~{...~} enumerate list items?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Thu, 15 Aug 2024 03:11 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (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: <v9jrlk$qiqk$1@dont-email.me>
References: <v79cj0$2115e$1@dont-email.me>
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=
View all headers

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

1

rocksolid light 0.9.8
clearnet tor